简体   繁体   English

create-react-app 安装,但无法通过“start”运行

[英]create-react-app installs, but fails to run with "start"

On Windows 10 with NodeJS portable version 12.4.0 (I'm on a corporate computer and don't have access to install NodeJS).在带有 NodeJS 便携式版本 12.4.0 的 Windows 10 上(我在公司计算机上,无权安装 NodeJS)。

When I run npx create-react-app myApp , it runs fine with no errors.当我运行npx create-react-app myApp ,它运行良好,没有错误。 I should mention I have an existing app (created months ago) which still runs fine on the same machine, but uses an older version of react-scripts.我应该提到我有一个现有的应用程序(几个月前创建),它在同一台机器上仍然运行良好,但使用了旧版本的 react-scripts。

When I run npm run start , i'm presented with this error:当我运行npm run start ,我看到了这个错误:


events.js:177
      throw er; // Unhandled 'error' event
      ^

Error: spawn cmd ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
    at onErrorNT (internal/child_process.js:456:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:9)
Emitted 'error' event at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12)
    at onErrorNT (internal/child_process.js:456:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:9) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn cmd',
  path: 'cmd',
  spawnargs: [ '/c', 'start', '""', '/b', 'http://localhost:3000/' ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! req@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the req@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.```




It seems to be a problem with your environment variables when using react-scripts@3.1.8 See: https://github.com/facebook/create-react-app/issues/6985使用 react-scripts@3.1.8 时,您的环境变量似乎有问题,请参阅: https : //github.com/facebook/create-react-app/issues/6985

Just downgrade you react-scripts' version and it should work:只需降级您的 react-scripts 版本,它应该可以工作:

create-react-app my-app
cd my-app
npm install react-scripts@2.1.8
npm start

I would recommend handling that error.我建议处理该错误。 If you need something more specific than that, it seems like we would need to see the code.如果您需要比这更具体的东西,我们似乎需要查看代码。

You can also use a process manager such as PM2 to automatically restart your bot whenever it crashes.您还可以使用进程管理器(例如 PM2)在机器人崩溃时自动重新启动它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM