[node]nvm installation, node version management, common error reporting

foreword

If only one version of node is installed, an error may be reported when running some vue projects,
such as:

  • When the node version is too low: SyntaxError: Unexpected token '.'syntax error -> ES feature does not support the problem
  • When the node version is too high: npm 报错npm ERR! code 1(or npm installit takes a long time, and reify:rxjs: timing reifyNodethe error message mentioned above appears at the end)
    so you need to install an nvm to manage the node version.

install nvm

Installation environment: window10 + non-system disk + scientific

(if any) uninstall the previous node

(1) Open the cmd command line window, enter the "where node" command and press Enter to output the installation path of nodejs.
(2) Delete all the files in the same folder as node.exe
(3) Uninstall nodejs on the page of uninstalling the application in windows
Complete! (I suddenly thought of it when I wrote this, it seems that the configuration in the system settings has not been deleted, but the problem is not big 0 0)

Install using set-up

  • When I use the installation-free version, after completing the configuration according to the tutorial, when I enter it, nvm -vit shows that nvm is not an internal or external command. It may be a wrong configuration. When I try again, I choose to use the set-up version, and it succeeds once.

Download address :

First create 2 folders, nvm and nodejs, at the same level, put them under the non-system disk, and select them when set-up.
Use the set-up version, just click the next step all the way, and you don’t need to deal with system variables or anything later (probably? Forget it (add it when you install it next time) (remember it will be automatically configured after the installation is complete)

Enter nvm -vReturning a value means the installation was successful.
Because it has been scientific, there is no need to change the source.

install node/npm

The next step is to install the commonly used Node version.
Currently I have 2 installed, one is 12.18.0 and the other is 16.18.0 which is enough for me.

nvm list availableShow partial list of downloadable versions

However, some node versions may not have npm, so when using it, there may be errors such as
the npm command (npm: command not found) that cannot be used after installing nvm to manage the node version .

Install & use specified version node:

nvm install 12.18.0

nvm use [version]: Use a certain version of node.
nvm list View the installed version
nvm list installed View the installed version
nvm install [version]: Install the specified version of node.js.
nvm list: List which versions of node are currently installed.
nvm uninstall [version]: Uninstall the specified version of node.

Enable nvm When using nvm for the first time, you need to enable nvm and use nvm oncommands to generate nodejs shortcuts.

nvm use 12.18.0

Then you can use it~

Reference:
nvm installation and configuration, very detailed
steps to uninstall node + install nvm
use nvm to manage node version, there is installation

Guess you like

Origin blog.csdn.net/sinat_41838682/article/details/130377821