项目场景:

npm run dev 启动一个 vue 项目报错。
在这里插入图片描述

错误日志:

 info it worked if it ends with ok
 verbose cli [
 verbose cli   'D:\\nodejs\\node.exe',
 verbose cli   'D:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
 verbose cli   'run',
 verbose cli   'dev'
 verbose cli ]
 info using npm@6.14.8
 info using node@v14.15.1
 verbose run-script [ 'predev', 'dev', 'postdev' ]
 info lifecycle ruoyi@3.1.0~predev: ruoyi@3.1.0
 info lifecycle ruoyi@3.1.0~dev: ruoyi@3.1.0
 verbose lifecycle ruoyi@3.1.0~dev: unsafe-perm in lifecycle true
 verbose lifecycle ruoyi@3.1.0~dev: PATH: D:\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\ddpapa\Desktop\new\volun-ui\node_modules\.bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;D:\java\jdk1.8.0_202\bin;D:\Git\cmd;D:\nodejs\;C:\Program Files\MySQL\MySQL Shell 8.0\bin\;C:\Users\ddpapa\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Bandizip\;D:\Microsoft VS Code\bin;C:\Users\ddpapa\AppData\Roaming\npm;
 verbose lifecycle ruoyi@3.1.0~dev: CWD: C:\Users\ddpapa\Desktop\new\volun-ui
 silly lifecycle ruoyi@3.1.0~dev: Args: [ '/d /s /c', 'vue-cli-service serve' ]
 silly lifecycle ruoyi@3.1.0~dev: Returned: code: 1  signal: null
 info lifecycle ruoyi@3.1.0~dev: Failed to exec dev script
 verbose stack Error: ruoyi@3.1.0 dev: `vue-cli-service serve`
 verbose stack Exit status 1
 verbose stack     at EventEmitter.<anonymous> (D:\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
 verbose stack     at EventEmitter.emit (events.js:315:20)
 verbose stack     at ChildProcess.<anonymous> (D:\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
 verbose stack     at ChildProcess.emit (events.js:315:20)
 verbose stack     at maybeClose (internal/child_process.js:1048:16)
 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
 verbose pkgid ruoyi@3.1.0
 verbose cwd C:\Users\ddpapa\Desktop\new\volun-ui
 verbose Windows_NT 10.0.17763
 verbose argv "D:\\nodejs\\node.exe" "D:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
 verbose node v14.15.1
 verbose npm  v6.14.8
 error code ELIFECYCLE
 error errno 1
 error ruoyi@3.1.0 dev: `vue-cli-service serve`
 error Exit status 1
 error Failed at the ruoyi@3.1.0 dev script.
 error This is probably not a problem with npm. There is likely additional logging output above.
 verbose exit [ 1, true ]


解决方案:

在电脑的环境变量中添加 C:\Windows\System32,之后需要重启电脑才可生效哦!
在这里插入图片描述

Tip:网上也还有一种方法就是在环境变量中添加%SystemRoot%\system32,前提是你的环境变量里有 SystemRoot 变量。
在这里插入图片描述

Logo

前往低代码交流专区

更多推荐