gpt4 book ai didi

reactjs - 尝试运行npm start命令时出错

转载 作者:行者123 更新时间:2023-12-03 09:56:30 27 4
gpt4 key购买 nike

我正在尝试创建一个React项目,我先运行npx create-react-app my-app然后运行cd my-app,但是当我运行npm start
已显示此错误:

> my-app@0.1.0 start C:\Users\USER\my-app
> 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\HAMOOD\my-app\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! my-app@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-app@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\HAMOOD\AppData\Roaming\npm-cache\_logs\2020-08-23T13_09_04_330Z-debug.log
我试图删除node_modules,然后再次安装了它,但是仍然发生相同的问题

最佳答案

我找到了一些可能的解决方案。似乎您使用的是Powershell,请首先检查您的Powershell是否为%SystemRoot%/system32/WindowsPowerShell/v1.0。之后,以管理员身份打开powershell并编写

Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
如果powershell出现问题,应该会有所帮助。或者,有时在cra dev服务器尝试打开W​​eb浏览器时可能是错误。 github上的某人说这对他有帮助:

This error stems from the fact that CRA tries to open your browser:In order to skip opening the browser, addBROWSER=noneto your .env or .env.local file


另一种方法是使用这些命令将项目的 react 脚本降级
npm install react-scripts@2.1.8
npm start

关于reactjs - 尝试运行npm start命令时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63547473/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com