【报错】react 运行报错 Error: spawn powe

2020-09-12  本文已影响0人  suesoft
1、错误

换了台电脑,运行react项目报了错误:Error: spawn powershell ENOENT,完整如下:

Starting the development server...
events.js:288
      throw er; // Unhandled 'error' event
      ^
Error: spawn powershell ENOENT    【******注意这一行报错******】
    at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
    at onErrorNT (internal/child_process.js:469:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)
    at onErrorNT (internal/child_process.js:469:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn powershell',
  path: 'powershell',
  spawnargs: [
    '-NoProfile',
    '-NonInteractive',
    '–ExecutionPolicy',
    'Bypass',
    '-EncodedCommand',
    'UwB0AGEAcgB0ACAAIgBgACIAaAB0AHQAcAA6AC8ALwBsAG8AYwBhAGwAaABvAHMAdAA6ADMAMAAwADAAYAAiACIA'
  ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-todolist@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-todolist@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2020-09-12T05_08_04_228Z-debug.log
PS E:\xieshu\works\react-todolist>
2、解决方案

Error: spawn powershell ENOENT,这是因为Path环境变量下找不到powershell.exe,需要在Path环境变量添加powershell.exe所在的目录。powershell所在的目录是:C:\Windows\System32\WindowsPowerShell\v1.0


电脑右键属性->高级系统设置->高级->环境变量->Path ->编辑 ->新建如图所示环境变量,确认后,重启编辑器,重启项目就可以了。

image.png
上一篇下一篇

猜你喜欢

热点阅读