Command not found even thought it is installed on Linux - linux

I recently installed nodejs in a remote centos server following the instruction on https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-a-centos-7-server for installing a package from the node site, since the nodejs that was installed using yum was v 0.something.
The installation went well, and node seems to be working, but only when I execute
/usr/local/bin/node or npm for that matter.
If I try just
node or npm I get the following error:
-bash: /usr/bin/node: No such file or directory
This is a little strange because my PATH does have /usr/local/bin/, and if I do
which node
I get
/usr/local/bin
Here is a copy/paste from the server
[root#v468996 local]# echo $PATH;
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
[root#v468996 local]# /usr/local/bin/node -v
v11.5.0
[root#v468996 local]# which node
/usr/local/bin/node
[root#v468996 local]# node
-bash: /usr/bin/node: No such file or directory
Note I know I can just make symlink on /usr/bin, so I'm not really asking about that, I want to know why node won't run even though it is installed, and in a location within PATH

As #tink said, this seemed to be the shell remembering the old node location.

Related

Npm command not found after launch build.sh file

I installed nvm and then installed npm by nvm install npm.
Nvm and npm have been installed to my main directory ~/.nvm and ~/.npm.
And yes, npm command is correct in every directory in the server on the ssh connection in console.
I added also build.sh file where I wrote npm run prod command and added this in post-receive git hook.
BUT! When I send new commits to this server, I see in console note like "npm command not found".
WHY????
After all, on the server everything is okay!
I tried also move ~/.npm to /usr/local/bin/ but it wasn't help. Probably because .npm it is a folder. I don't know...
I solved problem by deleting .nvm and .npm folders and installing npm through sudo apt-get. I guess it automatically have added needs files in needs directories to make npm command globally available.
In spite of I solved the problem by another way, I want to know what I was doing incorrectly in the first approach, cause maybe in the future I need nvm. Can someone experienced in linux explain me what the problem was?
Make sure the absolute path where npm command was installed is listen within your PATH variable, then make sure you export this variable so your build.sh script can see the new value and search for npm binary.
echo $PATH
export PATH="/path/to/my/installation/:$PATH"
echo $PATH
./build.sh

Node won't upgrade beyond v6.11.2

When I run node -v I see:
node -v
v6.11.2
I run brew update, brew upgrade, and update all npm modules every morning when I turn on my MacBook. I have npm 6.4.1.
I went to the Node downloads website, downloaded the installer, and installed v10.13.0. node -v still says v.6.11.2. I restarted my computer, ran the install again, no change.
I think I see the problem. When I run echo $PATH is see:
/Users/TDK/.rvm/gems/ruby-2.2.3/bin:
/Users/TDK/.rvm/gems/ruby-2.2.3#global/bin:
/Users/TDK/.rvm/rubies/ruby-2.2.3/bin:
/Users/TDK/.nvm/versions/node/v6.11.2/bin:
/usr/local/mysql/bin:/Users/TDK/google-cloud-sdk/bin:
/usr/local/heroku/bin:
/usr/local/bin:
/usr/bin:
/bin:
/usr/sbin:
/sbin:
/Users/TDK/.rvm/bin
/usr/local/bin is the path to Node, so that's good. But above it is a path to /Users/TDK/.nvm/versions/node/v6.11.2/bin. I need to get rid of that path. I opened /etc/paths and saw:
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
It looks like I have another paths file somewhere. All those paths above /usr/local/bin were installed when I was in coding bootcamp, I can get rid of all of them. Where might this other paths file be? I tried Spotlight to search for the first path, it couldn't find any file containing that string.
It looks like these are all path for one specific user /Users/TDK/ (that's me), not global paths for all users. Is there somewhere in /Users/TDK/ with paths? I commented out and then deleted lines involving RVM in the following files, without fixing the problem.
~/.bashrc
~/.bash_profile
~/.profile
I checked these files but didn't see anything suspicious:
/etc/profile
/etc/bashrc
Another thought is that nvm is causing the problem. The path
/Users/TDK/.nvm/versions/node/v6.11.2/bin:
is the problem. Maybe instead of removing this path I can alter nvm to point to the latest version of node?
Do you want to remove node 6.11.2 from your computer?
If not, just run nvm install node. That will install the lastest node, if you want to install a specific version, run nvm install 10.10.0 instead
Then run nvm use node or nvm run node --version

npm commands not working on Bash on Ubuntu on Windows (WSL)

I am running latest stable windows with bash on Ubuntu running through cmder wslbridge (i tried running directly through bash but same errors). Moving to my windows based react-native folder and trying to run some cli like npm run android , react-native run-android , gradlew clean is always producing errors;
while surprisingly some other commands like npm start work properly...
which npm print out; /usr/local/bin/npm
i have npm installed on windows and inisde Ubuntu and whereis npm produce this
I am really confused here; when running npm commands inside the bash onto windows folders which npm should be triggered? the windows or WSL one?!
I've tried a lot of suggested solution, but nothing seems to be working...
As you have said you are unsure what is actaully running when you run the commands. if you run the following commands it might make it clear as to what is actually running.
➜ ~ whereis npm
npm: /usr/local/bin/npm /home/damo/.nvm/versions/node/v8.11.1/bin/npm /mnt/c/Program Files/nodejs/npm /mnt/c/Program Files/nodejs/npm.cmd
➜ ~ which npm
/home/damo/.nvm/versions/node/v8.11.1/bin/npm
➜ ~ npm --version
6.4.1
➜ ~ sudo find / -name npm
/home/damo/.npm/10.52.63.39_4783/npm
/home/damo/.npm/npm
/home/damo/.nvm/versions/node/v10.4.1/bin/npm
/home/damo/.nvm/versions/node/v8.11.1/bin/npm
/home/damo/.oh-my-zsh/plugins/npm
/mnt/c/Program Files/nodejs/node_modules/npm
/mnt/c/Program Files/nodejs/node_modules/npm/bin/npm
/mnt/c/Program Files/nodejs/npm
/mnt/c/Users/stangerd/AppData/Roaming/npm
➜ ~ echo $PATH
/home/damo/.nvm/versions/node/v8.11.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Program Files/cmder/vendor/conemu-maximus5/ConEmu/Scripts:/mnt/c/Program Files/cmder/vendor/conemu-maximus5:/mnt/c/Program Files/cmder/vendor/conemu-maximus5/ConEmu:/mnt/c/Program Files/Docker/Docker/resources/bin:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/HashiCorp/Vagrant/bin:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/nodejs:/mnt/c/Program Files/Beyond Compare 4:/mnt/c/ProgramData/chocolatey/bin:/mnt/c/Program Files/Microsoft VS Code/bin:/mnt/c/Program Files/Docker/Docker/resources/bin:/mnt/c/Users/ stangerd/AppData/Roaming/npm
➜ ~ nvm use 10
Now using node v10.4.1 (npm v6.1.0)
➜ ~ echo $PATH
/home/damo/.nvm/versions/node/v10.4.1/bin:/usr/local/sbin:/usr/local/bin:........
You can see that for me i also have many versions of npm, but that its my WSLs current nvm version that is being used (shown by running which npm). This is because when the path is searched the first one found will be used. the first instance of npm in all the folders in my path is in /home/damo/.nvm/versions/node/v8.11.1/bin. Notice that when using nvm the path will be changed when switching node versions and that conveniently it puts this new path on the front of all the existing path folders.
Its also worth checking the alias set as this gets evaluated before the path is even queried. Just run alias to get a list.
Hope that this helps to find what is actually running. I'm interested to hear how you get on.

node -bash: /usr/sbin/node: No such file or directory

I am having this error with node. Running Debian 7 (Wheezy) a VPS.
I have this error if I for example run this command (in the directory of the .js)
node sell.js
or
screen node sell.js
They both don't work, because I am getting this error:
-bash: /usr/sbin/node: No such file or directory
Can somebody help me?
As in #Quentin's answer, the name of the executable may be incorrect. In many cases, what got installed was nodejs, not node. The line below creates a symbolic link that points to nodejs from where your system looks when you type node. It is a work-around - an alternative to simply typing nodejs
sudo ln -s /usr/bin/nodejs /usr/sbin/node
The Debian package for NodeJS is called nodejs and installed the executable /usr/bin/nodejs.
node is the wrong program, it is for ham radio operations, and your install of it appears to be broken anyway).
I ran the command:
sudo apt-get install nodejs-legacy
and nodejs worked again!
Maybe something wrong happened during your node's installing.
And system environment variable shows the command "node" referes to /usr/sbin/node .
Try download node linux binaries from official. Rename and put it in /usr/sbin after extracting the source. Of course you can put it in another folder as long as you update the system environment variables.

Can't build atom on Linux

I followed these steps to build atom on Linux on my own.
After cloning atom, i tried to run script/build. But i get an error "No such file or directory".
Node v0.10.31
Npm v0.10.31
I don't now how can I run these atom-build-script.
After searching, i found a solution to fix this issue.
[1] after installing node via apt, its command is nodejs, not node like its recommended to use these build-script
[1.1] after removing apt's node installation, i build node by my own
[2] run which node, to find out where you install node
[3] to run the build-script: /opt/node/bin/node your-atom-path/script/build
additional information how to fix from atom-github-build-instructions
"/usr/bin/env: node: No such file or directory
If you get this notice when attempting to script/build, you either do not have Node.js installed, or node isn't identified as Node.js on your machine. If it's the latter, entering sudo ln -s /usr/bin/nodejs /usr/bin/node into your terminal may fix the issue."

Resources