Download binaries from Nodejs download, eg. node-v6.11.5-linux-x64.tar.xz
Extract to /home/{ ubuntu username }/Develop/Application
Add export PATH=/home/{ ubuntu username }/Develop/Application/node-v6.11.5-linux-x64/bin:$PATH to the last line of the hiden file /home/{ ubuntu username }/.bashrc
Execute
source /home/{ ubuntu username }/.bashrc
Execute
node --version; npm --version
It will show the versions if the installation is successful.
Get current global location of npm
$ npm config get prefix
Install a package
// global
$ npm i { package name } -g
// local
$ npm i { package name }
// update package.json
$ npm i { package name } -S
Install a package with the specified version
$ npm install axios@0.17.1
Update a package
$ npm update axios
List packages
// global
$ npm list -g
$ npm list -g --depth=0
// local
$ npm list
$ npm list --depth=0
Uninstall
$ npm uninstall { package name }
Use package.json file to manage the dependencies
$ npm init
Update all packages in package.json.
$ npm install npm-update-all -g
// under the directory of package.json
$ npm-update-all
Set registry
$ npm config set registry { registry URL }
Get current registry
$ npm config get registry
Actually, for npm config get/set, it simply gets/sets the key values in the config map, ie. registry is a key and its URL is its value in config map.
Here are some commonly used npm commands.
Install nodejs and npm (for Ubuntu)
Download binaries from Nodejs download, eg.
node-v6.11.5-linux-x64.tar.xz
Extract to
/home/{ ubuntu username }/Develop/Application
Add
export PATH=/home/{ ubuntu username }/Develop/Application/node-v6.11.5-linux-x64/bin:$PATH
to the last line of the hiden file/home/{ ubuntu username }/.bashrc
Execute
source /home/{ ubuntu username }/.bashrc
Execute
node --version; npm --version
It will show the versions if the installation is successful.Get current global location of npm
$ npm config get prefix
Install a package
Install a package with the specified version
$ npm install axios@0.17.1
Update a package
$ npm update axios
List packages
Uninstall
$ npm uninstall { package name }
Use package.json file to manage the dependencies
$ npm init
Update all packages in package.json.
Run npm for different directory
$ npm { command } --prefix { path/to/another/directory }
Registry config
Set registry
$ npm config set registry { registry URL }
Get current registry$ npm config get registry
Actually, fornpm config get/set
, it simply gets/sets the key values in the config map, ie.registry
is a key and its URL is its value in config map.