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

Com*_*ode 5 reactjs create-react-app

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

 npx create-react-app react-tutorial
Run Code Online (Sandbox Code Playgroud)

...我收到以下错误:

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 > fsevents@2.0.6: Please update: there are crash fixes
[2/4] Fetching packages...
[-----] 1/1297Missing dependencies in package.json
Run Code Online (Sandbox Code Playgroud)

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

npm cache clean --force       
Run Code Online (Sandbox Code Playgroud)

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

mga*_*cia 5

看来这个错误是在这个问题中讨论的:

这似乎是一个纱线问题。

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

create-react-app myproject --use-npm
Run Code Online (Sandbox Code Playgroud)

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

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

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

ulimit -n 20000
Run Code Online (Sandbox Code Playgroud)