Node.js not found - node.js

I am using ubuntu 10.10, I installed nodejs from source ( ./configure && make && sudo make install ) and all done successfully. I tried to start nodejs CLI using
node
it says
bash: /usr/sbin/node: No such file or directory
note : i also referred these following questions
Express.js: No Such file or directory,
nodejs vs node on ubuntu 12.04
but still not able to rectify.

never mind, i found node in /usr/local/bin/node.
so the following command made it work.
sudo ln -s /usr/sbin/node /usr/local/bin/node

Related

/usr/bin/env node : not found while executing sudo node

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.

Installed Node.js but File Cannot be Found by Command Prompt

I installed node.js onto my Raspberry Pi, which is running on Raspbian Stretch.
To install, I used the command $ sudo apt-get install -y nodejs. There were no problems with installation.
When I try to test the installation by typing $ nodejs -v into the command prompt, it returns
nodejs: command not found
If I try to install it again, the prompt returns
nodejs is already the newest version (8.11.1~dfsg-2~bpo9+1)
Also, when I look into my /usr/bin folder, I see that node.js is there.
I've spent a while searching for what could be causing this issue to no avail. I think maybe the node.js file is in the wrong folder, but none of the tutorials I've read has a step where you would move the file.
Any help to get node.js to work would be greatly appreciated! :)
Try this:
Step 1: This command updates our Debian apt package repository to include the NodeSource packages.
$ curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
Step 2: Install NodeJS (THis will ensure you are installing latest version)
sudo apt install -y nodejs
Step 3: Enjoy NODEJS in RaspberryPi
$ node -v
v10.6.0
$ node
> 1 + 3
4
> # We can hit Ctrl-C twice to exit the REPL and get back to the bash (shell) prompt.
If you are having conflicts with previous NODE installations, do this to remove all existing installations:
Running which node will return something like /path/bin/node
Then run cd /path
Then run rm -r bin/node bin/node-waf include/node lib/node lib/pkgconfig/nodejs.pc share/man/man1/node.1
Hope it helps!

Running node in command line w/o sudo

I installed NodeJS on my Ubuntu server and now I'm wondering why I can't use it by simply typing "node". "nodejs" works fine, but only "node" should work, too, right?
"sudo node" works as well, so I thought this might be a problem with the PATH, but the PATH variables are identical:
root#myserver:/# node -v
-bash: /usr/sbin/node: No such file or directory
root#myserver:/# sudo node -v
v8.2.1
root#myserver:/# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
root#myserver:/# sudo echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
What am I doing wrong here? Thx.
I have had this issue in the past. I started installing Node like this on Ubuntu I have never had any issues with just using the node command, it has just worked:
rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/{npm*,node*,man1/node*}
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
Let me know if this works. You can read more about it here: https://nodejs.org/en/download/package-manager/
Did you install using apt-get? This is not recommended. Remove nodejs package and install from nodejs.org, https://nodejs.org/en/download/current/
You might also want to consider using something like nvm to manage your node versions, https://github.com/creationix/nvm
Using nvm you can solve this issue, and as a plus, it gives you the ability to install multiple node versions and bind the node command to whichever version you prefer
After installing nvm:
nvm install vX.Y.Z
nvm alias default vX.Y.Z
node -v // vX.Y.Z

Rookie error with Node.js, Johnny Five and Raspbian

I'm currently trying to communicate with Arduino through a web server created with Node.js installed on my Orange PI PC. In order to do this, I tried to use the module called johnny five, but the only output I receive is a bunch of errors.
I'm using Raspbian v0.8.0 for Orange PI PC.
I installed node v0.10.0 by using wget plus the link.
Then, I unpacked the file by using:
cd /usr/local
sudo tar xzvf ~/node-v0.10.0-linux-arm-pi.tar.gz --strip=1
The version of node is 0.10.0 and the NPM's version is 1.2.14. When I tried to update the npm with the command npm install npm -g
these errors came in
Then, I tried to install johnny-five by following the guide that I've found on the johnny-five website which is linked to Github
And this happened
If I try to run a program, many error appear saying at the top of them 'cannot find module johnny five'.
This version of node is the only one that works for me after checking many other of them.
Try and set up a more advanced version of node.js. I had success with node v4. This will update NPM/Node.
# install updates
sudo apt-get update && sudo apt-get upgrade
# install node
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
# test
node -v
npm -v
# clone the code of the project in a folder and continue normally
You can find an old version in the Heroku web:
https://node-arm.herokuapp.com/
But if you want a more recent go to https://nodejs.org/en/download/ and dowload a new one from Linux Binaries (ARM). Unzip the binary archive to any directory you wanna install Node, I use /usr/lib/nodejs:
sudo mkdir /usr/lib/nodejs
sudo tar -xJvf node-v8.9.4-linux-armv7l.tar.xz -C /usr/lib/nodejs
sudo mv /usr/lib/nodejs/node-v8.9.4-linux-armv7l /usr/lib/nodejs/node-v8.9.4
Set the environment variable ~/.profile, adding below to the end:
# Nodejs
export NODEJS_HOME=/usr/lib/nodejs/node-v8.9.4
export PATH=$NODEJS_HOME/bin:$PATH
Refresh profile:
.~/.profile
Test installation using:
node -v
and
npm version

Installing NPM on AWS EC2

Working on Ec2 on AWS.
I have installed Node.js and it works fine.
But the problem arises when trying to install npm.
I am using the following command to install it:
sudo curl http://npmjs.org/install.sh | sh
But the install seems to freeze...
I get "fetching: http://registry.npmjs.org/npm/-/npm-1.0.106.tgz" at the prompt and it stays on like this.
Have any idea what is going on here?
sudo yum install nodejs npm --enablerepo=epel
Follow this AWS Tutorial that uses Node Version Manager.
Node Version Manager (NVM) lets you install multiple versions of Node.js and switch between them.
Here are the steps:
Install NVM
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.0/install.sh | bash
Activate NVM
. ~/.nvm/nvm.sh
Install Node (choose version)
nvm install 15.0.0
Confirm Successful Installation
node -e "console.log('Running Node.js ' + process.version)"
To install NodeJS 6.x execute the following commands:
curl -sL https://rpm.nodesource.com/setup_6.x | sudo -E bash -
yum install nodejs --enablerepo=nodesource
Update
You can install NodeJS 7 and 8 in the same way. Just specify the version you need instead of 6 in the command above.
Update
To update to NodeJS 16 (or any other version) do the following:
rm -rf /etc/yum.repos.d/nodesource-el*
curl -sL https://rpm.nodesource.com/setup_16.x | sudo -E bash -
yum install nodejs --enablerepo=nodesource
Simplest way to install npm/nodejs on Amazon Linux 2 ec2 isntance:
First install epel repo using amazon-linux-extras command as below:
sudo amazon-linux-extras install epel
Now install npm and nodejs as below:
sudo yum install nodejs npm
you can verify the version of node and npm as below:
node -v
npm -v
PS. I've tested this on Amazon Linux 2 AMI (HVM) ec2 instance.
This guide worked perfectly: https://tecadmin.net/install-latest-nodejs-amazon-linux/
Make sure you have make
# sudo yum install -y gcc-c++ make
Install source
# curl -sL https://rpm.nodesource.com/setup_14.x | sudo -E bash -
Install node
# sudo yum install -y nodejs
Note - you'll have to run sudo npm install to get the installs to work.
Firstly
sudo yum install make
You can run this to get zip of desired version of node
wget https://nodejs.org/dist/v8.10.0/node-v8.10.0.tar.gz
Then you can unzip it like this
tar -xvf node-v8.10.0.tar.gz
then go in to the extracted directory and install node like this
./configure && make && sudo make install
I found his tutorial that has been very usefull to me: The last chapter explains how to install node and npm compiling it.
http://iconof.com/blog/how-to-install-setup-node-js-on-amazon-aws-ec2-complete-guide/#installNode
Get the http://npmjs.org/install.sh file on your system first and then execute it directly instead of piping with curl.
Use chmod +x install.sh to make it executable
Then run ./install.sh
I did it manually. Why mess with installers that break or don't put things where I want them? Such were the problems encountered while installing *node.js" on Amazon Web Services, that a manual install was the easy way to get the result I wanted.
I want a GLOBAL install of node and npm on AWS. By that I mean install should be put in a place like /usr/bin, so that all users have access. Surprisingly, AWS apparently doesn't give support to that idea. AWS encourages using nvm, node version manager, but that seems to always install in a user directory, and not a system level directory. After being frustrated when the "rpm" solutions (mentioned elsewhere) failed, I finally decided to just do the installation manually.
In a browser, go to nodejs.org download page:
https://nodejs.org/en/download/
Find a link that says:
All download options
Click through that; it goes to an index page with a URL like:
https://nodejs.org/dist/v14.16.1/
There I looked for the name that had "linux" and "x86" in the name.
I wrote this down, or select-and-copied, to get the correct spelling.
In my case it was:
node-v14.16.1-linux-x64.tar.gz
Putting the two parts together, I got the following URL:
https://nodejs.org/dist/v14.16.1/node-v14.16.1-linux-x64.tar.gz
So that's what is to be downloaded using curl.
I have a "temp" directory conveniently located in my home dir.
cd ~/temp
The download was accomplished with "curl". Note that the -o option was used to give the output file the name of my choosing. Of course, I chose to give it the same name as the web site file.
curl -o node-v14.16.1-linux-x64.tar.gz https://nodejs.org/dist/v14.16.1/node-v14.16.1-linux-x64.tar.gz
Untar the downloaded file.
tar xf node-v14.16.1-linux-x64.tar.gz
Conveniently, it creates its own directory. Go there.
cd node-v14.16.1-linux-x64 || exit 1;
Observe that the delivery consists of a relatively small number of files and directories (since node_modules is dealt with as a unit).
In my case, I had an old and bad implementation still installed, so the following commands were used to move aside any junk that might happen to be in the way. Some commands errored out because the old junk didn't exist. That's ok, error while moving to -OLD just means there is nothing to move; which is good.
Note: I put all these mv (move) commands into a script file, made it executable, and ran it as sudo. The alternative is to run each line individually as sudo.
mv /usr/bin/node /usr/bin/node-OLD
mv /usr/bin/npm /usr/bin/npm-OLD
mv /usr/bin/npx /usr/bin/npx-OLD
mv /usr/include/node /usr/include/node-OLD
mv /usr/lib/node_modules /usr/lib/node_modules-OLD
mv /usr/share/doc/node /usr/share/doc/node-OLD
mv /usr/share/man/man1/node.1 /usr/share/man/man1/node.1-OLD
mv /usr/share/systemtap/tapset/node.stp /usr/share/systemtap/tapset/node.stp-OLD
An here is the actual install. Remember, this is occurring in the untarred directory, in my case node-v14.16.1-linux-x64.
mv bin/node /usr/bin
mv bin/npm /usr/bin
mv bin/npx /usr/bin
mv include/node /usr/include
mv lib/node_modules /usr/lib
mv share/doc/node /usr/share/doc
mv share/man/man1/node.1 /usr/share/man/man1
mv share/systemtap/tapset/node.stp /usr/share/systemtap/tapset/
That's it, all finished.
Latest version 18 has dependency I think..
node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by node)
Finally I got solution by running by running following commands.
sudo apt-get remove nodejs
nvm install 16.15.1
v16.15.1 node version and npm v v16.15.1 is installed.
For same make sure nvm is installed in your machine.
This works for me:
sudo apt install npm
Edit as my answer wasn't pertinent anymore:
Try:
curl --silent --location https://rpm.nodesource.com/setup | bash -
yum -y install nodejs
https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager#enterprise-linux-and-fedora-core

Resources