I'm trying to install nodeJs into my Ubuntu 14.04 in order to use GruntJs.
I've read about Ubuntu different way of doing it (issues?), so this is what I've done in order to install it:
sudo apt-get install npm sudo npm install -g grunt-cli
Typing grunt after that I've got the error:
/usr/bin/env: node: No such file or directory
So, I've tried:
curl -sL https://deb.nodesource.com/setup | sudo bash - sudo apt-get install -y nodejs sudo apt-get update
And trying again, and still getting the error, I've tried:
sudo add-apt-repository https://launchpad.net/~chris-lea/+archive/node.js/ sudo apt-get install -y nodejs
I've got this message:
nodejs is already the newest version. 0 to upgrade, 0 to newly install, 0 to remove and 3 not to upgrade.
I did try a cleanup just in case:
sudo apt-get autoremove
But nope, the error is still there: when I type grunt I still get /usr/bin/env: node: No such file or directory
What should I do?
#!/usr/bin/env node is an instance of a shebang line: the very first line in an executable plain-text file on Unix-like platforms that tells the system what interpreter to pass that file to for execution, via the command line following the magic #! prefix (called shebang).
How to install npm via Node. Now that nvm is installed, we're ready to do what we really wanted to do in the first place: install npm and Node on our system. It's not a bad idea to confirm nvm is installed properly, by running nvm -v . If the terminal shows you the installed version number, you're good to go!
Doing a symlink solves the issue:
ln -s /usr/bin/nodejs /usr/bin/node
(My thanks and +1 vote to bodokaiser's answer).
The issue is not with the version of node. Instead, it is the way NodeJS is installed by default in Ubuntu. When running a Node application in Ubuntu you have to run nodejs somethign.js
instead of node something.js
So the application name called in the terminal is nodejs
and not node
. This is why there is a need for a symlink to simply forward all the commands received as node
to nodejs
.
sudo ln -s /usr/bin/nodejs /usr/bin/node
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With