尝试运行npm start命令时出错

问题描述

我正在尝试创建一个我已经运行npx create-react-app hello-react --use-npm然后cd hello-react的react项目,但是当我启动npm时,已显示错误

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,但未显示任何错误就没有打开

解决方法

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

npm install react-scripts@2.1.8
npm start
,

创建一个新文件夹,然后尝试以下操作:

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

,

您可以尝试在路径C:\windows\System32上重新安装节点

或者您可以

请按照以下步骤操作:

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

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...