NPM Upgrade
Don't say much nonsense, just talk about the steps. Start with the easy first and upgrade NPM.
NPM This package management tool has been criticized by people, many people recommend the use of yarn, but its number of users are still not reduced, and NPM are installed with node at the same time, let me abandon it, or a bit difficult to do.
npm i -g npm
Yes, you've read it right. Upgrading NPM is just like installing a different package, which can be upgraded under Windows and Linux, and you can also specify the version of NPM.
npm i -g [email protected]5.0.0
Node upgrade
Node escalation is a bit more complicated than NPM.
1, first install node's version management tool through NPM "n", do not be surprised, the name is so simple, called N. It is understood that N is a module under node, and the author is the developer of the Express framework.
npm i -g n
2. Check N module
Check the installation path of the system node first, and the default path for the N module is '/usr/local '.
$ which node/data/home/server/nodejs/bin/node #举个例子
If the path is the same as the default path of the N module, you can skip 3 steps.
3. Modify the default node installation path for n through the N_prefix variable.
(1) Editing the Environment configuration file
vim ~/.bash_profile
(2) Insert the following two lines of code at the end of the file
export N_PREFIX=/data/home/server/nodejs #node实际安装位置export PATH=$N_PREFIX/bin:$PATH
(3): Wq save exit;
Executes the source to make the modification effective.
source ~/.bash_profile
(4) Confirm that the environment variable is in effect.
echo $N_PREFIX/data/home/server/nodejs
4, N module common commands
COMMANDS:N Output versions installed n latest Install or activate th E Latest node Release n-a x86 latest as above but force32 bit architecture n Stable Install or activate the latest stable node R Elease n lts Install or activate the latest LTS node release n <version> Install node <version> n use <version> [args for <version> N rm <version
...> Remove the given version (s) n prune Remove all versions except the current version n--late St Output the latest node version available n--stable output the latest stable node version available n--lts output the Latest LTS node version available n ls Output the versions of node available
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
(1) Install node's latest version
n latest
(2) Install stable version
n stable
(3) Install the specified version
n v7.10.0
(4) View installed version
n
(5) Delete the specified version
n rm 6.4.0
Finally, Linux also has a shell-based node management tool NVM, interested students can also try their own.
Upgrade NPM and node under Linux