【问题标题】:Error when trying to run npm start command尝试运行 npm start 命令时出错
【发布时间】:2020-12-18 23:58:36
【问题描述】:

我正在尝试创建一个反应项目,我已经运行了 npx create-react-app hello-react --use-npm 然后 cd hello-react 但是当我运行 npm start 时显示此错误:

npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\develompent\Desktop\react\package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\develompent\Desktop\react\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\develompent\AppData\Roaming\npm-cache\_logs\2020-08-30T18_43_59_773Z-debug.log

C:\Users\develompent\Desktop\react>cd hello-react

C:\Users\develompent\Desktop\react\hello-react>npm start

> hello-react@0.1.0 start C:\Users\develompent\Desktop\react\hello-react
> react-scripts start

i 「wds」: Project is running at http://192.168.137.1/
i 「wds」: webpack output is served from
i 「wds」: Content not from webpack is served from C:\Users\develompent\Desktop\react\hello-react\public
i 「wds」: 404s will fallback to /
Starting the development server...

events.js:292
      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! hello-react@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the hello-react@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\develompent\AppData\Roaming\npm-cache\_logs\2020-08-30T18_44_47_550Z-debug.log

我试图删除 node_modules 然后我再次安装它但同样的问题仍然发生 我也尝试以管理员身份运行 cmd,但它没有打开而没有显示任何错误

【问题讨论】:

    标签: reactjs npm cmd npm-start


    【解决方案1】:

    创建一个新文件夹并尝试以下操作:

    npx create-react-app my-app
    cd my-app
    npm start
    

    您的机器上需要有 Node >= 8.10 和 npm >= 5.6

    https://reactjs.org/docs/create-a-new-react-app.html

    【讨论】:

      【解决方案2】:

      你可以尝试在C:\windows\System32路径下重新安装node

      或者你可以

      按照以下步骤操作:

      • npm cache clean --force
      • 删除node_modules文件夹
      • 删除package-lock.json文件
      • npm install

      【讨论】:

        【解决方案3】:

        使用这些命令降级项目的反应脚本

        npm install react-scripts@2.1.8
        npm start
        

        【讨论】:

          猜你喜欢
          • 2021-01-08
          • 1970-01-01
          • 2021-01-01
          • 2020-12-21
          • 1970-01-01
          • 1970-01-01
          • 2023-03-07
          • 2022-01-05
          相关资源
          最近更新 更多