Linux version to replace the node and npm

Node upgrade

  • node n may be used to upgrade the node and mpm. n is a node of a first version of the tool installed n Tools:
npm install -g n
  • N After you install this version management tool can be upgraded in the node and npm.
  • Install the most stable version of the node
n stable
  • Install the latest version:
n latest
  • Delete a version:
n rm 10.13.0 
  • N-Switch Version
n   --回车
    node/10.13.0
  ο node/10.15.3
    node/11.0.0
    node/11.8.0
    node/12.2.0
# 按上下键选择版本后,回车
  • npm upgrade:
npm i -g npm
  • You can also perform npm version:
npm i -g [email protected]

Problems encountered

Although the system prompts successful, but did not appear as expected when viewing version node and npm on the machine Shique desired version, there is no change, but just obviously a successful installation. The reason for this is that different modules and installation path of node n. Solution:

1. Check the installation path node system:

# which node
root@iZuf60tpfwhkw3rz3et056Z:/usr/gocode/src/github.com/hyperledger/fabric-samples/fabcar# which node
/usr/bin/node

This file is a link here on my computer actually point location:

/usr/local/download/node-v8.9.2/bin/node

Prior to reference other blog because I installed a new version of the node, the modified link file (topic):

ln -s /usr/local/download/node-v8.9.2/bin/node /usr/bin/node

2. node to modify the default installation path variable n by N_PREFIX

  • Edit profile file:
vim  /etc/profile
  • As shown in the following statement added
export N_PREFIX=/usr/local/download/node-v8.9.2 #node实际安装位置
export PATH=$N_PREFIX/bin:$PATH
  • The command execution source file to take effect
source /etc/profile

N module and then re-use version to replace the command.

Published 40 original articles · won praise 7 · views 10000 +

Guess you like

Origin blog.csdn.net/weixin_44617722/article/details/104861261