Node version management tool gnvm

In daily learning, when you want to run the code of the predecessors in github or gitee, due to the iteration of the version, you will encounter various version problems, such as

ERROR

[eslint] Must use import to load ES Module: C:\Users\xzc\Desktop\react-blog\node_modules\@eslint\eslintrc\universal.js
require() of ES modules is not supported.
require() of C:\Users\xzc\Desktop\react-blog\node_modules\@eslint\eslintrc\universal.js from C:\Users\xzc\Desktop\react-blog\node_modules\eslint\lib\linter\linter.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename universal.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from C:\Users\xzc\Desktop\react-blog\node_modules\@eslint\eslintrc\package.json.

Therefore, a gnvm is recommended here to freely switch the version of node

1. Download and install

Click to open the URL , and download the 64-bit or 32-bit version according to your own computer (because it is downloaded from an external network, the speed may be very slow), the installation process is skipped
insert image description here

2. Put gnvm.exe into the folder where Node.js is located

Put the downloaded gnvm.exe file into the previously installed node.js installation directory. If you don’t know the node.js installation directory, you can use the command line to view it

where node

insert image description here
insert image description here

3. Check whether gnvm is installed

Check gnvm version

gnvm version

insert image description here

Four, gnvm common commands

gnvm version //查看版本
gnvm ls // 查看已安装的node.js版本
gnvm install latest // 安装最新版本的node.js
gnvm install *.*.* // 安装指定版本的node.js
gnvm update latest // 更新本地的latest为最新版本
gnvm uninstall latest //卸载最新版本的node.js
gnvm uninstall *.*.* // 卸载指定版本的node.js
gnvm use *.*.* // 切换已下载好的node.js版本
gnvm search *.*.* //查找node.js版本(由于小版本过多,最好大的版本号,如gnvm search 12.*.*,查找12的版本)

5. Possible problems

Question 1

gnvm use *.*.*This problem when switching node versions is used Access is denied.., as follows:

Error: copy D:\Nodejs\\ to D:\Nodejs\\12.16.0 folder Error: open D:\Nodejs\\12.16.0\node.exe: Access is denied..

At this time, it may be due to insufficient permissions. I can switch successfully when I start cmd as an administrator.
insert image description here

Question 2
Error: copy D:\Nodejs\\12.16.0 to D:\Nodejs\\ folder Error: open D:\Nodejs\\\node.exe: The process cannot access the file because it is being used by another process..

The prompt is that the node program is running, check the running project and ctrl+cclose the project, and it will be fine when switching again

6. Installation URL of historical version of node

Guess you like

Origin blog.csdn.net/skybulex/article/details/125512007