NPM update and NodeJS update

Update your installed NPM library. This is as simple as running it.

npm update -g
Copy the code

Update Nodejs itself. I have been relying on the latest version of the source is to download, and then make install, and cumbersome. All you need to do is run the following two commands:

npm install -g n 
Copy the code
n latestCopy the code


n

Is a module of Node written by TJ Holowaychuk, and as its name suggests, the idea is simple:

The installation

npm install -g n1Copy the code

After the installation is complete, type n

You can select the version you want to use by moving up or down arrow keys, and press Enter to take effect.

N 0.10.1 0.10.15o 0.10.21 0.11.812345Copy the code

Install the latest version

n latest1Copy the code

Installing the Stable Version

n stable1Copy the code

Delete a version

N the rm 0.10.11Copy the code

Executes the script at the specified version

N use 0.10.21 some js1Copy the code

The error Windows_NT 6.1.7601

npm install -g n --force
Copy the code


The node version does not change after the node version is changed

The command line code is as follows:

Bash

# n
# node -vCopy the code

After the switch, the Node version does not change, which is a little awkward. Solutions are as follows:

Bash

export NODE_HOME=/usr/local
export PATH=$NODE_HOME/bin:$PATH
export NODE_PATH=$NODE_HOME/lib/node_modules:$PATHCopy the code

Then you can happily switch, estimating the possible cause: Node may have been taken over by NVM. Therefore, n switchover fails.