NPM (Node Package Manager)
-
Install and update npm
sudo apt-get install npm ## Will pull NodeJS sudo npm install -g n sudo n latest
-
References: how can I update Nodejs, and install Ubuntu
-
Installing from the installer
-
Installing with the CLI
iex (new-object net.webclient).downstring(‘https://get.scoop.sh’) scoop install nodejs
-
Installing from nodist
brew install npm
- Avoid installing packages (i.e. using
npm install
) outside of npm hierarchies (places where nopackage.json
is present). Otherwise this will install the package in your homedirectory which might provoke later collisions. - In case of trouble clear your npm cache (refer below)
Once npm is installed, swsitching npm version can be done with npm itself e.g.
npm install -g [email protected]
In a similar fashion updating (to lastest) nom can be done with
npm install npm@latest -g
Ubuntu note: you might need to sudo e.g. sudo npm install -g [email protected]
-
List all the globally installed packages:
npm list -g --depth=0
-
Clearing the cache:
npm cache clean --force
Note that the cache is located in ~/.npm on Posix -
List packages within a directory:
npm ls