Javascript create react应用程序安装,但无法使用“运行”;“开始”;

Javascript create react应用程序安装,但无法使用“运行”;“开始”;,javascript,reactjs,create-react-app,Javascript,Reactjs,Create React App,在Windows 10上安装NodeJS portable版本12.4.0(我在公司计算机上,没有安装NodeJS的权限) 当我运行npx create react app myApp时,它运行良好,没有错误。我应该提到我有一个现有的应用程序(几个月前创建的),它在同一台机器上仍然运行良好,但使用的是旧版本的react脚本 当我运行npm run start时,出现以下错误: events.js:177 throw er; // Unhandled 'error' event

在Windows 10上安装NodeJS portable版本12.4.0(我在公司计算机上,没有安装NodeJS的权限)

当我运行npx create react app myApp时,它运行良好,没有错误。我应该提到我有一个现有的应用程序(几个月前创建的),它在同一台机器上仍然运行良好,但使用的是旧版本的react脚本

当我运行
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.```





我建议处理这个错误。如果您需要比这更具体的东西,我们似乎需要查看代码


您还可以使用进程管理器(如PM2)在bot崩溃时自动重新启动它。

使用react时,您的环境变量似乎有问题-scripts@3.1.8 见:

只需降低react脚本的版本,它就可以工作了:

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

git shell中的系统路径变量中可能缺少C:\Windows\System32。。尝试运行:导出路径=$PATH:C:\Windows\System32。然后重新运行命令。不幸的是,我不能这样做,因为它需要管理员权限,而我没有管理员权限。我正在PowerShell中使用
$env:Path=“c:\nodejs”
设置路径。这也适用于我以前的应用程序。在发布这个问题后不久,我注意到如果我将package.json中的“react scripts”从默认的
3.0.1
更改为
2.1.8
,然后运行
npm I
,它就会工作。那么是什么原因呢?react脚本3.0.1是怎么回事?好的,我想你必须降低react脚本的版本。看看我的答案。