node.js - 即使正确的 npm/node 版本,Create-react-app 也不能在“npm start”工作
问题描述
- 我正在学习本教程的反应。我收到一个关于没有启动脚本的错误,使用我的文本编辑器添加到 package.json 文件中。现在我真的不知道如何解决我的新错误。
- 更新了我的 package-json 文件,卸载并重新安装了 create-react-app,创建了新的 react-app 文件夹,读取了堆栈溢出。使用“npx react-scripts start”手动启动它。
我的 npm -v (6.7.0) 和 node -v (12.16.0)
react-app 的文件目录树
- 节点模块
- 使用 create-react-app 创建文件夹时添加的文件夹列表
- 上市
- favicon.ico
- 索引.html
- 清单.json
源代码
- index.js
- .gitignore
- 包.json
- 包-lock.json
- 自述文件.md
- 节点模块
错误:
circulating@CLAPP-T460-22 MINGW64 ~/Desktop/react-app (master)
$ npm start
> react-app@1.1.0 start C:\Users\circulating\Desktop\react-app
> react-scripts start
i 「wds」: Project is running at http://192.168.1.16/
i 「wds」: webpack output is served from
i 「wds」: Content not from webpack is served from C:\Users\circulating\Desktop\re act-app\public
i 「wds」: 404s will fallback to /
Starting the development server...
events.js:287
throw er; // Unhandled 'error' event
^
Error: spawn cmd 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 cmd',
path: 'cmd',
spawnargs: [ '/s', '/c', 'start', '""', '/b', '"http://localhost:3000/"' ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-app@1.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-app@1.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional log ging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\circulating\AppData\Roaming\npm-cache\_logs\2020-06-07T01_ 12_36_919Z-debug.log
解决方案
将 C:\Windows\System32 添加到全局 PATH 环境变量中。
或者
使用不同的 react 脚本版本重新安装你的 npm。只需在命令中转到您的文件夹并像这样重新安装: npm install react-scripts@2.1.8 npm start
推荐阅读
- node.js - linux VM 上的 NodeJS 托管,以及从 Windows 到 Linux 的 http 请求
- php - 从两个不同表中的相同字段名称中获取数据并检测我们指的是哪个字段名称
- vb.net - 使用 vb.net 和 SDCA Trainer 的 ML.NET 问题
- java - 使用 List java 流时对 Set 对象进行嵌套过滤
- sql - 将主键列数据复制到同一张表的其他列中
- python-3.x - 为什么测试失败,是否可以替代使用?
- python-3.x - 如何使用 Python 将文件从 Ubuntu 传输到 Windows
- dask - 如何使用 Dask 对大文本文件进行排序?
- amazon-web-services - 在 aws sam DeploymentPreference 中为 CodeDeployHook 指定自定义 CodeDeployServiceRole 角色
- docker - 带有私钥的 Jenkins SSH 用户名发送到调用 docker 容器的脚本