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
- First clear the npm cache:
npm cache clean -f
- Install the node version management tool
n
;
npm install n -g
- View all versions of node
npm view node versions
- Upgrade node version
n 16.0.0
n stable
n latest
- 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
- View the location of the node installed by n
which node
/usr/local/n/versions/node/16.0.0
- enter the location
cd /usr/local/n/versions/node
- edit
/etc/profile
vim /etc/profile
- 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
- Enter
wq
and exit to save the file, and then compile /etc/profile
;
source /etc/profile
- Review the version number
node -v
16.0.0