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

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.

Related

Command not found even thought it is installed on 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.

Running electron as root on Linux

I am making an application with electron which uses the wiring-pi library. This needs access to the GPIO on my Raspberry Pi, which requires root.
When I run electron . in the folder, the app opens fine but then says (in the terminal):
wiringPiSetup: Must be root. (Did you forget sudo?)
However when I try sudo electron ., I get an error:
sudo: electron: command not found
Does anyone know why this is happening?
Also, for the record, the same thing happens when I run npm as root:
pi#raspberrypi:~/rubiks-robot $ sudo npm
sudo: npm: command not found
Any ideas of how I can fix this issue and run Electron as root?
it looks like a problem of environment variables. The environmnet variables are set for your user but not for root.
Try to ship your variables with the "-E" switch of the sudo command:
sudo -E command
Please try to see here for other similar questions
How to keep Environment Variables when Using SUDO

How can I get the slc command to work on Ubuntu?

I have installed Strongloop using npm install -g strongloop on my Ubuntu 14.04 server. The slc command does not work. It says
The program 'slc' is currently not installed. You can install it by typing:
sudo apt-get install heimdal-multidev
How can I get it to run the Strongloop CLI instead of looking for this package? I have added this to my PATH and it still doesn't work. Any ideas?
Other Strongloop commands, like sl-build work and strongloop is listed in npm list -g.
Ubuntu 14 with node.js 4.1.2
By default somehow slc is not created or not added to PATH.
I solved this problem by adding symlink:
sudo ln -s /usr/lib/node_modules/strongloop/bin/slc.js /usr/bin/slc
A soft link named slc should have been created at /usr/local/bin which will point to strongloop binary.
Please verify if the following exists.
/usr/local/lib/node_modules/strongloop/bin/slc
If no, then strongloop did not get installed successfully, otherwise verify the existence of the softlink slc at /usr/local/bin/.
/usr/local/bin/slc -> /usr/local/lib/node_modules/strongloop/bin/slc
If yes, then /usr/local/bin needs to be added to the $PATH, otherwise create the softlink and verify that /usr/local/binin $PATH.
Looks like the Node installation that optionally comes with a Digital Ocean Droplet installs to a different location that's not in $PATH. I'm pretty sure that was the issue. Anyways, I fixed it by spinning up a server without Node pre-installed and followed this guide. Just use npm install -g strongloop instead of strong-cli because the latter has been deprecated.
Ubuntu 14.04 with node.js 4.4.2 (LTS) :
The installation of strongloop was done without any errors but slc was not added to the PATH. I solved this problem by adding the symlink:
sudo ln -s /usr/local/lib/node_modules/strongloop/bin/slc.js /usr/bin/slc
Actually i am not sure my case matches with yours but i want to share my experience. i got the same message anyway.
I realized that i had changed prefix of global packets before. Then i checked prefix with the following command.
$ npm config get prefix
/home/myUser/.node_modules_global
Then i added the path to PATH variable (but .profile, .bash_profile files will be better) in active command line window and problem solved.

node user directory leading to command not found

I suipidly ran this script to stop having to use sudo on npm -g commands and now my node_modules are located at:
/Users/myusername/.npm-packages/lib/node_modules
when trying to run a commands i.e yo bower i get -bash: bower: command not found
Do I need to link this directory to the usr/bin?
In trying to sort this out I have run lots of commands and created symbolic links, I feel like my system is a real mess and I cannot really see what is going on? Help to ensure my system is clean would be really helpful.
Generally, it's a good idea to ensure that you do not need admin rights to run npm commands. The problem you're having, is that the directory where npm now installs its commmands (/Users/myusername/.npm-packges/bin) is not in your PATH. Your PATH is a list of directories where your shell searches for the commands you type.
You can add the directory to your path by adding the following line to the .bashrc file in your home directory (create it if it doesn't exist).
export PATH="${PATH}:/Users/myusername/.npm-packages/bin"
Open a new terminal, and bower should work again.
As an additional tip, I believe you're running on OS X? When installing Node.js using Homebrew, it is automatically installed in a proper way (no sudo needed to install packages globally and they will just work). Next time you're installing Node.js (or something else), Homebrew might be worth a try.

node.js on Raspberryp]Pi not showing any terminal output

I've installed node.js on my RaspberryPi running Raspbian using
sudo apt-get install nodejs npm
it looks as though it has installed, I got no errors on installation, but when I check the version, I don't get any terminal output from node -v or node --version.
I wrote a simple js file just outputting test to the console, and when I run that from the command line with node index.js, I also don't get any output in the command line.
Is there something I'm doing wrong here? is the Raspbian terminal in some way different from other platforms (I can't imagine it is).
I've also installed following the directions in this post (up to configuring the server) http://blog.rueedlinger.ch/2013/03/raspberry-pi-and-nodejs-basic-setup/ and get the same result, no output in the console
The debian packages for node.js usually don't provide the binary as node (/usr/bin/node) but rather as nodejs (/usr/bin/nodejs) due to possible naming conflict with another binary from another package. (See also http://ypcs.fi/howto/2013/03/23/nodejs-debian/ for example) So you should call nodejs -v etc.
Alternatively/additionally, you can create a symbolic link with ln -s /usr/bin/nodejs /usr/bin/node. Useful expecially if you have to run shell script that expect node to be named node.
I ended up having to re-create my raspbian image (not sure why), and after trying countless different ways of installing node, I ended up using this script https://github.com/midnightcodr/rpi_node_install, it took forever, but it worked in the end.
I've also more recently seen posts which say sudo apt-get install node-js, but didn't try that one myself.

Resources