一、yarn serve 啟動vue項目,如下報錯:
Type checking in progress...
App running at:
- Local: http://localhost:8080/crmpc/
- Network: http://172.20.3.3:8080/
Note that the development build is not optimized.
To create a production build, run yarn build.
events.js:352
throw er; // Unhandled 'error' event
^
Error: spawn cmd ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
at onErrorNT (internal/child_process.js:467:16)
at processTicksAndRejections (internal/process/task_queues.js:82:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
at onErrorNT (internal/child_process.js:467:16)
at processTicksAndRejections (internal/process/task_queues.js:82:21) {
errno: -4058,
code: 'ENOENT',
syscall: 'spawn cmd',
path: 'cmd',
spawnargs: [ '/c', 'start', '""', '/b', 'http://172.20.3.3:8080' ]
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
二、報錯原因:
電腦缺少cmd運行程序的環境變量
三、解決方案:
環境變量Path中添加C:\Windows\System32
或者 %SystemRoot%\system32
具體步驟:
右鍵我的電腦--高級系統設置--高級--環境變量--系統變量,找到Path,添加就可以了
注意:設置完記得關閉vscode,重新啟動vscode才可以生效哦!