/usr/bin/env node : not found while executing sudo node - node.js

I've a dedicated vps running on cent os. I installed node on that by using
yum install nodejs
It installed successfully without any error and it shows version also.
node -v
v10.16.0
But it shows an error while running this with sudo
sudo node
Command not found
And when I try to run npm with sudo it shows
sudo npm
/usr/bin/env: node: No such file or directory
I tried many solutions from here like
ln -s /usr/bin/nodejs /usr/bin/node
and many more.
I've also tried reinstalling node but still no luck.

Related

Command node -v shows bash: /usr/local/bin/node: No such file or directory

I have a non working node on my raspberry pi 4 (buster). :(
npm -v shows version 6.14.5 and nodejs -v shows v10.21.0 but node -v shows only
"bash: /usr/local/bin/node: No such file or directory"
But a file named /usr/local/bin/node is there.
The Command
n latest
shows
installing : node-v14.6.0
mkdir : /usr/local/n/versions/node/14.6.0
fetch : https://nodejs.org/dist/v14.6.0/node-v14.6.0-linux-arm64.tar.xz
/usr/local/bin/n: line 633: /usr/local/bin/node: No such file or directory
installed : (with npm 6.14.6)
I had the same issue and this is how I solved it
Remove the files in usr/local/bin/node using this command sudo rm -rf /usr/local/bin/node*. You could optionally choose to manually remove npx, n or whichever node related package that you've installed
Run sudo apt install nodejs and then check the version using node -v
Run sudo apt install npm then npm -v
After that, run curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash then restart the terminal
Finally run nvm install 16
This should solve your issue, it did for me!

nodejs command not found on VPS

While setting up a Centos7 VPS server via SSH I have the problem that NodeJS command isn't found.
Installing the latest stable version of nodejs using:
curl —silent —location https://rpm.nodesource.com/setup_10.x | sudo bash -
...results in the instruction: Run 'sudo yum install -y nodejs' to install Node.js 10.x and npm
...running the above command it says: nodejs-10.16.3-1nodesource.x86_64 already installed and latest version
But if I then check the installed versions it isn't found:
[root#server ~]# node -v
v10.16.3
[root#server ~]# npm -v
6.9.0
[root#server ~]# nodejs -v
-bash: nodejs: command not found
I've seen several sources usins nodejs -v to check the version but I'm half convinced they're wrong. Although followup tests like nano also fail.
I've tried re-installing several different ways but it results in the same result.
Add an alias to node can solve your problem.

sudo: node: command not find on EC2 Ubuntu

When run sudo node --version on EC2 Ubuntu, error: sudo: node: command not find appears.
I have read similar questions and answers published in stackoverflow, but no one works in myside...
my node js is in /home/ubuntu/remoteserver/deviceServer.js, when I run sudo node deviceServer.js in the directory remoteserver, error: sudo: node: command not find appears. It is the same when I run outside the directory...
when I run whereis node, I got:
node: /usr/bin/node /usr/lib/node /home/ubuntu/.nvm/versions/node/v10.7.0/bin/node
when I run which npm, I got:
/home/ubuntu/.nvm/versions/node/v10.7.0/bin/npm
Could you please help?
It appears node in not in properties of root. But first of all, why do you need sudo to run node. You can directly do node deviceServer.js.
If you want compulsorily to use sudo. Execute below before running sudo node
sudo ln -s /usr/local/bin/node /usr/bin/node
sudo ln -s /usr/local/lib/node /usr/lib/node
sudo ln -s /usr/local/bin/npm /usr/bin/npm

Cannot install ember on ubuntu 1404

I've installed nodejs and npm on my ubuntu. Then I installed ember on my machine and I typed ember -v to verify that ember has installed successfully. But I got the following message from the terminal:
/usr/bin/env: node: No such file or directory
I have accidently installed node (instead of nodejs) but then I removed it... now when I type node in terminal, it gives me:
The program 'node' can be found in the following packages:
* node
* nodejs-legacy
Try: apt-get install <selected package>
what I have to do to install ember properly?
Run
which nodejs
in my case it displayed /usr/bin/nodejs
Make a link
sudo ln -s /usr/bin/nodejs /usr/sbin/node
it should work afterwards

bash commandline jslint wont scan file and wont give an error

Why wont my jslint scan a file in bash?
On a fresh install of kubuntu
I installed node
sudo apt-get install node
Then
sudo apt-get install npm
Then
sudo npm install jslint -g
All installs worked well with no errors
my issue comes when I type: I use tab to auto complete
a#a:~/Desktop$ jslint test.js
a#a:~/Desktop$
it does nothing just creates a new line why? the file clearly has errors
PS proof it all installed
a#a:~/Desktop$ nodejs -v
v0.10.25
a#a:~/Desktop$ npm -v
1.3.10
The issue was that I had installed node and not nodejs as they are two different thing
sudo apt-get install nodejs

Resources