【node】Upgrade Node version tutorial

windows system

  • The window system upgrade node can only go to the node official website to download the window installation package to overwrite the previous node.
  • Node installation tutorial with download address: https://blog.csdn.net/qq_45677671/article/details/114535955
  • Because the n module does not support the window system:
PS C:\Users\liuxing> npm install -g n
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for [email protected]: wanted {
    
    "os":"!win32","arch":"any"} (current: {
    
    "os":"win32","arch":"x64"})
npm ERR! notsup Valid OS:    !win32
npm ERR! notsup Valid Arch:  any
npm ERR! notsup Actual OS:   win32
npm ERR! notsup Actual Arch: x64

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\liuxing\AppData\Roaming\npm-cache\_logs\2022-11-03T09_24_21_102Z-debug.log

Mac or Linux system

  • Upgrade method: If the following command prompts that you have no permission, please add it in front of the command sudo, such assudo npm install n -g
  1. First clear the npm cache:
npm cache clean -f
  1. Install the node version management tool n;
npm install n -g
  1. View all versions of node
npm view node versions

insert image description here

  1. Upgrade node version
# 升级到指定的版本:n 版本号
n 16.0.0

# 升级到最新的稳定版本
n stable

# 升级到最新版本,不推荐
n latest 
  1. Use node -v to view the node version. If the version number changes to what you want, the upgrade is successful.
node -v
16.0.0
  • If the version number has not changed, you can restart the machine or try the following methods
  1. View the location of the node installed by n
which node
/usr/local/n/versions/node/16.0.0
  1. enter the location
cd /usr/local/n/versions/node
  1. edit/etc/profile
vim /etc/profile
  1. Add the node installation path to the end of the file;
export NODE_HOME=/usr/local/n/versions/node/16.0.0
export PATH=$NODE_HOME/bin:$PATH
  1. Enter wqand exit to save the file, and then compile /etc/profile;
source /etc/profile
  1. Review the version number
node -v
16.0.0

Guess you like

Origin blog.csdn.net/qq_45677671/article/details/127675036
Recommended