ubuntu 16.04 node npm issue

I am relatively new to ubuntu and don't know why it is so hard to set up the coding environment on ubuntu.

First, I don't know what is the best way to install node, i've used apt-get install nodejs, but I have to start with "nodejs app.js" which I really don't like to use instead of "node app.js". I've searched a several ways of installing node on ubuntu, and tried, I even forgot others ways of installing it. Now, my ubuntu can run "node" and I don't know which way I installed it.

Second, everything npm installed globally just don't work in the command line. it said : no command "xx" found. But I did install without errors using npm install -g xx I just tried "npm install -g jshint" and "npm install -g grunt-cli" and both not working in the command line. I suspect that the package is installed but located in another directory where the command line won't get info from that directory.

I guess the question is : How to install node and npm on Ubuntu(16.04) so that I can type "node -v" to get the version, and when I install packages globally using npm, I can run it on the command line.


The most convenient way to install node.js on every OS is use nvm

Follow instruction in this URL: https://github.com/creationix/nvm


by default as far as i remember, nodeJS repository in ubuntu still 0.10.x, while now already like 6.9.x

ok, lets follow this simple instruction:

first download the shell script to put the repo:

curl -sL https://deb.nodesource.com/setup_6.x -o nodesource_setup.sh

then run it

sudo bash nodesource_setup.sh

then do apt-update

sudo apt-get update

then install the nodeJS

sudo apt-get install nodejs

optional: you might need to add these package also

sudo apt-get install build-essential libssl-dev

by this time(October 26th, 2016) i think you should see 6.9.1 the moment you do node --version and as for npm, should be 3.10.8

链接地址: http://www.djcxy.com/p/27698.html

上一篇: NPM全局软件包在Ubuntu上不可用

下一篇: Ubuntu的16.04节点NPM问题