我正在尝试安装新版本的node和npm。已安装的node版本为18.3.0,由验证
<test> node --version
v18.3.0
然而,当我尝试使用npm
时,它抱怨说它不能在v18.3.0上运行,尽管它也声称它支持“>=18.0.0
”。
<test> npm --version
ERROR: npm v9.7.1 is known not to run on Node.js v18.3.0. This version of npm supports the following node versions: `^14.17.0 || ^16.13.0 || >=18.0.0`. You can find the latest version at https://nodejs.org/.
ERROR:
C:\Program Files (x86)\Nodist\npmv\9.7.1\node_modules\@npmcli\config:1
../../workspaces/config
^
SyntaxError: Unexpected token '.'
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1033:15)
at Module._compile (node:internal/modules/cjs/loader:1069:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Module._load (node:internal/modules/cjs/loader:827:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\Program Files (x86)\Nodist\npmv\9.7.1\lib\npm.js:2:16)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
更新:我安装了nodejs 18.16.0,我得到了相同的错误
ERROR: npm v9.7.1 is known not to run on Node.js v18.16.0. This version of npm supports the following node versions: `^14.17.0 || ^16.13.0 || >=18.0.0`. You can find the latest version at https://nodejs.org/.
ERROR:
C:\Program Files (x86)\Nodist\npmv\9.7.1\node_modules\@npmcli\config:1
../../workspaces/config
^
SyntaxError: Unexpected token '.'
at internalCompileFunction (node:internal/vm:73:18)
at wrapSafe (node:internal/modules/cjs/loader:1176:20)
at Module._compile (node:internal/modules/cjs/loader:1218:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Module._load (node:internal/modules/cjs/loader:958:12)
at Module.require (node:internal/modules/cjs/loader:1141:19)
at require (node:internal/modules/cjs/helpers:110:18)
at Object.<anonymous> (C:\Program Files (x86)\Nodist\npmv\9.7.1\lib\npm.js:2:16)
at Module._compile (node:internal/modules/cjs/loader:1254:14)
1条答案
按热度按时间ncgqoxb01#
尝试将Node.js更新到与npm 9.7.1兼容的版本。
要解决此问题,请安装最新的LTS(长期支持)版本。