Use nvm to manage and switch node versions

wrong description:

C:\Users\Y\AppData\Roaming\
pm\yarn.cmd install
yarn install v1.22.19
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning "@vue/cli-plugin-unit-mocha > [email protected]" has unmet peer dependency "webpack@^4.0.0".
warning " > [email protected]" has unmet peer dependency "webpack@^3.0.0 || ^4.0.0".
[4/4] Building fresh packages...
[-/4] ? waiting...
[2/4] ? yorkie
[-/4] ? waiting...
error D:\code\tiku-develop\source\front-end\tiku\
ode_modules\
ode-sass: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments:
Directory: D:\code\tiku-develop\source\front-end\tiku\
ode_modules\
ode-sass
Output:
Building: C:\Program Files\
odejs\
ode.exe D:\code\tiku-develop\source\front-end\tiku\
ode_modules\
ode-gyp\bin\
ode-gyp.js rebuild --verbose --libsass_ext = --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [ 'C:\Program Files\\
odejs\\
ode.exe',
gyp verb cli 'D:\code\tiku-develop\source\front-end\tiku\\
ode_modules\\
ode-gyp\bin\\
ode-gyp.js',
gyp verb cli 'rebuild',
gyp verb cli '--verbose',
gyp verb cli '--libsass_ext=',
gyp verb cli '--libsass_cflags=',
gyp verb cli '--libsass_ldflags=',
gyp verb cli '--libsass_library=' ]
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed at getNotFoundError (D:\code\tiku-develop\source\front-end\tiku\
ode_modules\which\which.js:13:12)
gyp verb `which` failed at F (D:\code\tiku-develop\source\front-end\tiku\
ode_modules\which\which.js:68:19)
gyp verb `which` failed at E (D:\code\tiku-develop\source\front-end\tiku\
ode_modules\which\which.js:80:29)
gyp verb `which` failed at D:\code\tiku-develop\source\front-end\tiku\
ode_modules\which\which.js:89:16
gyp verb `which` failed at D:\code\tiku-develop\source\front-end\tiku\
ode_modules\isexe\index.js:42:5
gyp verb `which` failed at D:\code\tiku-develop\source\front-end\tiku\
ode_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:153:21)
gyp verb `which` failed python2 { Error: not found: python2
gyp verb `which` failed at getNotFoundError (D:\code\tiku-develop\source\front-end\tiku\
ode_modules\which\which.js:13:12)
gyp verb `which` failed at F (D:\code\tiku-develop\source\front-end\tiku\
ode_modules\which\which.js:68:19)
gyp verb `which` failed at E (D:\code\tiku-develop\source\front-end\tiku\
ode_modules\which\which.js:80:29)
gyp verb `which` failed at D:\code\tiku-develop\source\front-end\tiku\
ode_modules\which\which.js:89:16
gyp verb `which` failed at D:\code\tiku-develop\source\front-end\tiku\
ode_modules\isexe\index.js:42:5
gyp verb `which` failed at D:\code\tiku-develop\source\front-end\tiku\
ode_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:153:21)
gyp verb `which` failed stack:
gyp verb `which` failed 'Error: not found: python2\
 at getNotFoundError (D:\code\tiku-develop\source\front-end\tiku\\
ode_modules\which\which.js :13:12)\
 at F (D:\code\tiku-develop\source\front-end\tiku\\
ode_modules\which\which.js:68:19)\
 at E(D
:\code\tiku-develop\source\front-end\tiku\\
ode_modules\which\which.js:80:29)\
 at D:\code\tiku-develop\ \source\front-end\tiku\\
ode_modules\which\which.js:89:16\
 at D:\code\tiku-develop\source\front-end\tiku\ \
ode_modules\isexe\index.js:42:5\
 at D:\code\tiku-develop\source\front-end\tiku\\
ode_modules\isexe\windows.js: 36:5\
 at FSReqWrap.oncomplete (fs.js:153:21)',
gyp verb `which` failed code: 'ENOENT' }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python C:\Users\Y\AppData\Local\Programs\Python\Python311\python.EXE
gyp ERR! configure error
gyp ERR! stack Error: Command failed: C:\Users\Y\AppData\Local\Programs\Python\Python311\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[ :3];
gyp ERR! stack File "<string>", line 1
gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
gyp ERR! stack SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:294:12)
gyp ERR! stack at ChildProcess.emit (events.js:198:13)
gyp ERR! stack at maybeClose (internal/child_process.js:982:16)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
gyp ERR! System Windows_NT 10.0.22621
gyp ERR! command "C:\Program Files\\
odejs\\
ode.exe" "D:\code\tiku-develop\source\front-end\tiku\\
ode_modules\\
ode-gyp \bin\\
ode-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd D:\code\tiku-develop\source\front-end\tiku\
ode_modules\
ode-sass
gyp ERR! node -v v10.24.1
gyp ERR! node-gyp -v v3.8.0
                                                                                                                                                                                                                                                                                   
                                                                                                                                                                                                                                                                                   
                                                                                                                                                                                                                                                                                   

Process ended with exit code 1

An error occurred in the yarn install command because the node-sass version did not correspond to the node version.

image.png

Manage node versions by installing nvm

Use nvm to manage and switch node versions

Install nvm-window github.com/coreybutler…, win10 adds system environment and user environment by default. If nvm cannot be used on the command line, you need to add the environment yourself.

Use mirroring
Find the settings.txt file in the nvm installation directory

node_mirror: npm.taobao.org/mirrors/nod…

npm_mirror: npm.taobao.org/mirrors/npm…

Install and use node.js via nvm
Use the install command to install different versions of node.js in nvm. For example, to install the 12.1.0 version of node.js:

nvm install 12.1.0

You can use the use command to switch to a certain version, such as:

nvm use 12.1.0

After the switch is completed, you can enter node -v and npm -v, and you can see that the version has been switched to the version you want to use.

Other nvm commands

nvm arch [32|64]: Displays whether the node is running in 32-bit or 64-bit mode. Specify 32 or 64 to override the default architecture.
-nvm install [arch]: This can be the node.js version or the latest stable version latest. (optional [arch]) Specifies to install the 32-bit or 64-bit version (default is system arch). Set [arch] to all to install 32- and 64-bit versions. Adding –insecure after the command can bypass the SSL verification of the remote download server.
nvm list [available]: Lists installed node.js versions. Optional available, displays a partial list of downloadable versions. This command can be abbreviated as nvm ls [available].
nvm on: Enable node.js version management.
nvm off: Disable node.js version management (do not uninstall anything)
nvm proxy [url]: Set the proxy for downloading. Leave [url] blank to view the current proxy. Set [url] to none to delete the proxy.
nvm node_mirror [url]: Set the node mirror, the default is https://nodejs.org/dist/.. It can be set as Taobao’s mirror https://npm.taobao.org/mirrors/node/
nvm npm_mirror [url]: Set the npm mirror, the default is https://github.com/npm/npm/archive/. It can be set as a Taobao mirror https://npm.taobao.org/mirrors/npm/
nvm uninstall: Uninstall the specified version of nodejs.
nvm use [version] [arch]: Switch to use the specified nodejs version. 32/64-bit [arch] can be specified.
-nvm use : will continue to use the selected version, but switch to 32/64-bit mode based on the provided value
nvm root [path]: Set the directory where nvm stores different versions of node.js. If not set, the current directory will be used.
-nvm version: Displays the currently running nvm version, which can be abbreviated as nvm v
se : will continue to use the selected version, but switch to 32/64-bit mode based on the value provided
nvm root [path]: Set the directory where nvm stores different versions of node.js. If not set, the current directory will be used.
-nvm version: Displays the currently running nvm version, which can be abbreviated as nvm v