The article was originally published at the Third Frontier Institute in SZHSHP
Reprint Please specify
Ubuntu 16.04 Installation Nodejs
Oh, my God, Linux installation Nodejs is so troublesome.
Nodejs Installation
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -sudo apt-get install -y nodejs
There may be errors that cannot be found. curl
apt-get
curl
NPM Installation
curl http://npmjs.org/install.sh | sudo shsudo apt-get install curl
Node VS NodeJS?
NPM, node installed after successful execution:
node -v
Found an error
-bash: /usr/sbin/node: No such file or directory
However, you can use
nodejs -v
The cause of this problem:
There is a naming conflict with the node package (amateur Packet Radio node program), and the Nodejs binary have been Renam Ed from node to Nodejs. You'll need to Symlink/usr/bin/node To/usr/bin/nodejs or you could uninstall the amateur Packet Radio node program to AV OID that conflict.
Of course, the direct use nodejs命令
can also execute node program, but subsequent if the installation of modules will appear node 未定义
error
The workaround is to add a link:
You need to manually create a symlink /usr/bin/node
. Shortcut for bash compatible shells:
sudo ln -s `which nodejs` /usr/bin/node
Or If you use non-standard shells, just hardcode the path to find with which Nodejs:
/usr/bin/nodejs /usr/bin/node
Npm:permission Denied
There is a problem with NPM installation Hexo:
node scripts/build_highlight_alias.js > highlight_alias.jsonsh: 1: cannot create highlight_alias.json: Permission denied
Change to sudo still error.
Solution See official Guide:https://docs.npmjs.com/getting-started/fixing-npm-permissions
Reference documents
- https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
- Http://www.cnblogs.com/seanlv/archive/2011/09/24/2189719.html
- https://stackoverflow.com/questions/18130164/nodejs-vs-node-on-ubuntu-12-04
- Https://github.com/hexojs/hexo-util/issues/9
Gracefully play Linux-3-ubuntu under Nodejs installation