尝试朗读npm start命令时出错 [英] Error when trying to rum npm start command
问题描述
我正在尝试创建一个我已经运行 npx create-react-app my-app
然后 cd my-app
,但是当我 npm start
时,显示此错误:
I am trying to create a react project i have run npx create-react-app my-app
then cd my-app
but when I've npm start
this error has been shown:
> 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,然后再次安装它,但是仍然存在相同的问题
i have tried to to delete the node_modules then I've installed it another time but the same issue still happening
推荐答案
我找到了一些可能的解决方案。似乎您正在使用Powershell,请首先检查您的Powershell是否为%SystemRoot%/ system32 / WindowsPowerShell / v1.0。在以管理员身份打开powershell之后,写
I've found some possible solutions. Seems that you are using powershell, check firstly that you have it in your PATH as %SystemRoot%/system32/WindowsPowerShell/v1.0. After that open powershell as admin and write
Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
如果powershell存在问题,它应该会有所帮助。或者,有时在cra dev服务器尝试打开Web浏览器时可能是错误。 github上的某人说这对他有所帮助:
It should help in case there is problem with powershell. OR, sometimes it could be an error while cra dev server is trying to open web browser. Someone on github said that this helped him:
此错误源于CRA尝试打开浏览器的事实:
为了跳过打开在浏览器中,将
BROWSER = none
添加到您的.env或.env.local文件中
This error stems from the fact that CRA tries to open your browser: In order to skip opening the browser, add
BROWSER=none
to your .env or .env.local file
另一种方法是使用这些命令降级项目的React脚本
Another way is to downgrade react scripts for project with these commands
npm install react-scripts@2.1.8
npm start
这篇关于尝试朗读npm start命令时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!