当我开始使用命令行npx create-react-app myapp
创建我的第一个应用程序时,它没有启动,当我使用npm start
时,出现以下错误。
运行命令后遇到的日志:
Starting the development server...
events.js:200
throw er; // Unhandled 'error' event
^
Error: spawn cmd ENOENT
←[90m at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)←[39m
←[90m at onErrorNT (internal/child_process.js:456:16)←[39m
←[90m at processTicksAndRejections (internal/process/task_queues.js:81:21)←[39m
Emitted 'error' event on ChildProcess instance at:
←[90m at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12)←[39m
←[90m at onErrorNT (internal/child_process.js:456:16)←[39m
←[90m at processTicksAndRejections (internal/process/task_queues.js:81:21)←[39m {
errno: ←[32m'ENOENT'←[39m,
code: ←[32m'ENOENT'←[39m,
syscall: ←[32m'spawn cmd'←[39m,
path: ←[32m'cmd'←[39m,
spawnargs: [ ←[32m'/s'←[39m, ←[32m'/c'←[39m, ←[32m'start'←[39m, ←[32m'""'←[39m, ←[32m'/b'←[39m, ←[32m'"http://localhost:3000/"'←[39m ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myapp@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the myapp@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\Believer\AppData\Roaming\npm-cache\_logs\2020-01-23T23_26_01_725Z-debug.log
c:\Users\Believer\Documents\React\myapp>
答案 0 :(得分:0)
首先删除node_modules目录,然后使用^([0-2][0-9]|(3)[0-1])(\.)(((0)[0-9])|((1)[0-2]))(\.)(\d{4}|\d{2})$
然后是npm install
然后killall node
大多数情况下,当有多个应用程序在使用节点服务器时,会发生此错误
您也可以通过更改端口来尝试
在项目根目录下创建一个 .env 文件,并在其中指定端口号。喜欢:
npm start
如果这都不起作用,则意味着您没有多个应用程序正在运行的问题