Vue 项目运行时,报错Error: Cannot find module ‘node:path’
internal/modules/cjs/loader.js:883
throw err;
^
Error: Cannot find module 'node:path'
Require stack:
- D:\nodejs\node_modules\npm\node_modules\node_modules\npm\lib\cli.js
- D:\nodejs\node_modules\npm\node_modules\node_modules\npm\bin\npm-cli.js
[90m at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)[39m
[90m at Function.Module._load (internal/modules/cjs/loader.js:725:27)[39m
[90m at Module.require (internal/modules/cjs/loader.js:952:19)[39m
[90m at require (internal/modules/cjs/helpers.js:88:18)[39m
at Object.<anonymous> (D:\nodejs\node_modules\[4mnpm[24m\node_modules\[4mnode_modules[24m\npm\lib\cli.js:2:18)
[90m at Module._compile (internal/modules/cjs/loader.js:1063:30)[39m
[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)[39m
[90m at Module.load (internal/modules/cjs/loader.js:928:32)[39m
[90m at Function.Module._load (internal/modules/cjs/loader.js:769:14)[39m
[90m at Module.require (internal/modules/cjs/loader.js:952:19)[39m {
code: [32m'MODULE_NOT_FOUND'[39m,
requireStack: [
[32m'D:\\nodejs\\node_modules\\npm\\node_modules\\node_modules\\npm\\lib\\cli.js'[39m,
[32m'D:\\nodejs\\node_modules\\npm\\node_modules\\node_modules\\npm\\bin\\npm-cli.js'[39m
]
}
输入node -v
如下:
输入npm -v
报错
原因:
node版本和npm版本不匹配
官网有具体版本匹配信息:https://nodejs.org/en/about/previous-releases
解决办法
更换匹配的node和npm版本,可参考:https://blog.csdn.net/xch_yang/article/details/140047103