create-react-app 抛出错误:“package.json 中缺少依赖项”

2024-05-13

所以我尝试运行reactjs官方教程并使用第一行代码:

 npx create-react-app react-tutorial

...我收到以下错误:

npx: installed 91 in 12.692s

Creating a new React app in /home/foo/projects/react-tutorial.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...

yarn add v1.12.3
[1/4] Resolving packages...
warning react-scripts > [email protected] /cdn-cgi/l/email-protection: Please update: there are crash fixes
[2/4] Fetching packages...
[-----] 1/1297Missing dependencies in package.json

我在其他地方阅读了一些清理或强制清理 npm 缓存的内容,但这也不起作用:

npm cache clean --force       

我在 ubuntu 上运行最新的节点 (10.16.0) 我也尝试过 8.*


看来这个错误是在这个讨论的issue https://github.com/facebook/create-react-app/issues/5918:

这似乎是一个纱线问题。

解决方法是使用 npm 而不是yarn:

create-react-app myproject --use-npm

如果使用 npm 安装,您会遇到以下错误:

npm 错误! cb() 从未调用过!

通过更新(或删除)以下命令来增加 .bashrc、.bash_profile 和/或 .profile 中的 ulimit:

ulimit -n 20000
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

create-react-app 抛出错误:“package.json 中缺少依赖项” 的相关文章

随机推荐