我尝试创建一个 React 应用程序。我用的是命令提示符但是在创建应用程序后,当我尝试启动 npm 时,它给了我一些错误。
我也尝试在 WebStorm、IntelliJ 和 Visual Studio Code / PowerShell 中创建 React 应用程序但仍然给出同一组错误.
这是我得到的错误:
Starting the development server...
events.js:174
throw er; // Unhandled 'error' event
^
Error: spawn cmd ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
Emitted 'error' event at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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\Lini Eisha\AppData\Roaming\npm-cache\_logs\2019-04-28T06_38_11_889Z-debug.log
C:\Windows\System32\af-project>
我尝试了很多事情,例如清理 npm 缓存、重新安装 npm 和 node、将 npm 升级到新版本、尝试升级 React 但没有任何效果。
但它应该启动 npm 并给 localhost 3000
- 检查您的节点版本。更新节点和 npm
- Try
sudo npm start
如果您使用的是 macOS 或 Linux
- 尝试再次下载create-react-app
npm i -g create-react-app
- 尝试在另一个文件夹中创建应用程序
create-react-app APPNAME
- 还是行不通?然后删除
node_module
文件夹,package-lock.json
并运行npm install
- 尝试在另一个端口上运行
- 尝试用
yarn
。安装Yarn
全局然后运行create-react-app myapp
再次。这次将使用纱线。尝试启动开发服务器yarn start
代替npm start
.
UPDATE
也可能有问题react-script
版本。您可以尝试降级react脚本,
create-react-app my-app
cd my-app
npm install [email protected]
npm start
另外,请确保您的目录中有此条目PATH
环境变量。
C:\Users\{user_name}\AppData\Roaming\npm
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)