我在Windows 10上;
我有一个用vue和node 14.16.1
开发的项目。
我正在学习一门vue课程,最后一步,我必须将构建的项目(dist
文件夹)上传到一个简单的firebase服务器中,使用firebase login
个
但是这个命令只适用于节点>=18,所以我使用了nvm
,nvm install 20.10.0
(最新LTS版本)nvm use 20.10.0
个
在这之前都没什么问题。
然后我在我的项目上运行了npm run serve
,问题来了(抱歉有这么多文字):
npm run serve
C:\Users\%USERNAME%\AppData\Roaming\nvm\v20.10.0\node_modules\npm\lib\es6\validate-engines.js:31
throw err
^
Error: Cannot find module '@npmcli/config'
Require stack:
- C:\Users\%USERNAME%\AppData\Roaming\nvm\v20.10.0\node_modules\npm\lib\npm.js
- C:\Users\%USERNAME%\AppData\Roaming\nvm\v20.10.0\node_modules\npm\lib\cli-entry.js
- C:\Users\%USERNAME%\AppData\Roaming\nvm\v20.10.0\node_modules\npm\lib\cli.js
- C:\Users\%USERNAME%\AppData\Roaming\nvm\v20.10.0\node_modules\npm\bin\npm-cli.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
at Module._load (node:internal/modules/cjs/loader:985:27)
at Module.require (node:internal/modules/cjs/loader:1235:19)
at require (node:internal/modules/helpers:176:18)
at Object.<anonymous> (C:\Users\%USERNAME%\AppData\Roaming\nvm\v20.10.0\node_modules\npm\lib\npm.js:2:16)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Module._load (node:internal/modules/cjs/loader:1023:12)
at Module.require (node:internal/modules/cjs/loader:1235:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\%USERNAME%\\AppData\\Roaming\\nvm\\v20.10.0\\node_modules\\npm\\lib\\npm.js',
'C:\\Users\\%USERNAME%\\AppData\\Roaming\\nvm\\v20.10.0\\node_modules\\npm\\lib\\cli-entry.js',
'C:\\Users\\%USERNAME%\\AppData\\Roaming\\nvm\\v20.10.0\\node_modules\\npm\\lib\\cli.js',
'C:\\Users\\%USERNAME%\\AppData\\Roaming\\nvm\\v20.10.0\\node_modules\\npm\\bin\\npm-cli.js'
]
}
Node.js v20.10.0
C:\Users\%USERNAME%\AppData\Roaming\nvm\v20.10.0\node_modules\npm\lib\es6\validate-engines.js:31
throw err
^
Error: Cannot find module '@npmcli/config'
Require stack:
- C:\Users\%USERNAME%\AppData\Roaming\nvm\v20.10.0\node_modules\npm\lib\npm.js
- C:\Users\%USERNAME%\AppData\Roaming\nvm\v20.10.0\node_modules\npm\lib\cli-entry.js
- C:\Users\%USERNAME%\AppData\Roaming\nvm\v20.10.0\node_modules\npm\lib\cli.js
- C:\Users\%USERNAME%\AppData\Roaming\nvm\v20.10.0\node_modules\npm\bin\npm-cli.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
at Module._load (node:internal/modules/cjs/loader:985:27)
at Module.require (node:internal/modules/cjs/loader:1235:19)
at require (node:internal/modules/helpers:176:18)
at Object.<anonymous> (C:\Users\%USERNAME%\AppData\Roaming\nvm\v20.10.0\node_modules\npm\lib\npm.js:2:16)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Module._load (node:internal/modules/cjs/loader:1023:12)
at Module.require (node:internal/modules/cjs/loader:1235:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\%USERNAME%\\AppData\\Roaming\\nvm\\v20.10.0\\node_modules\\npm\\lib\\npm.js',
'C:\\Users\\%USERNAME%\\AppData\\Roaming\\nvm\\v20.10.0\\node_modules\\npm\\lib\\cli-entry.js',
'C:\\Users\\%USERNAME%\\AppData\\Roaming\\nvm\\v20.10.0\\node_modules\\npm\\lib\\cli.js',
'C:\\Users\\%USERNAME%\\AppData\\Roaming\\nvm\\v20.10.0\\node_modules\\npm\\bin\\npm-cli.js'
]
}
字符串
(yes据我所知,由于某些原因,它找不到@npmcli
模块,但我没有使用它(我想)。
下面是我的package.json
文件:
{
"name": "vue-first-app",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^3.6.5",
"vue": "^3.3.10",
"vue-router": "^4.2.5",
"vuex": "^4.1.0"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"@vue/compiler-sfc": "^3.0.0-0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^7.0.0-0"
}
}
型
我试着检查我的环境变量,它们是:
x1c 0d1x的数据
由于这不是我第一次在项目中更新节点时遇到问题,我通常应该做些什么来避免这些问题?我现在应该怎么做?
1条答案
按热度按时间lg40wkob1#
解决了
该问题是在
1.1.7
-1.1.8
-1.1.9
nvm版本,我用的是nvmv1.1.7
。我只好道:
npm 20.10.0
到nvm remove 20.10.0
。记得检查命令行,有时会显示
Manually remove C:\Users\<user>\AppData\Roaming\nvm\v20.10.0.
nvm v1.1.12
或更高版本,使用nvm-setup.exe
,您可以在此link in github上找到;nvm v20.10.0
现在应该可以了。