我正在尝试创建一个我已经运行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,但未显示任何错误就没有打开
答案 0 :(得分:3)
使用这些命令降级项目的反应脚本
npm install react-scripts@2.1.8
npm start
答案 1 :(得分:1)
创建一个新文件夹,然后尝试以下操作:
npx create-react-app my-app
cd my-app
npm start
您需要在计算机上安装Node> = 8.10和npm> = 5.6
答案 2 :(得分:1)
您可以尝试在路径C:\windows\System32
上重新安装节点
或者您可以
请按照以下步骤操作:
npm cache clean --force
node_modules
文件夹package-lock.json
文件npm install