npm i create-react-app
、npx create-react-app new-app
和npm init react-app new-app
安装create-react-app
,但我一直收到以下错误信息:
我该如何解决?您正在运行create-react-app 4.0.0,落后于最新版本(4.0.1)。我们不再支持全局安装Create React App。
npm i create-react-app
、npx create-react-app new-app
和npm init react-app new-app
安装create-react-app
,但我一直收到以下错误信息:
我该如何解决?您正在运行create-react-app 4.0.0,落后于最新版本(4.0.1)。我们不再支持全局安装Create React App。
以下是对我有效的方法。
我尝试了之前回答中提到的命令。我逐个运行它们而不是将它们作为链接命令运行(以防其中任何一个失败)。但当我执行 create-react-app 命令时,它失败了。
npm uninstall -g create-react-app && npm i -g npm@latest && npm cache clean -f && npx create-react-app my-app
我不知道为什么,但即使我更新了npm并卸载了全局并清除了缓存,它也无法工作,直到我运行了
npm i create-react-app
npm uninstall create-react-app -g
npm i create-react-app
npm create-react-app@latest my-app
npm create-react-app@4.0.2 my-app
在浏览了Github的一些问题后,我找到了一个发布的解决方案,它不需要降级node或npm。
我正在使用WSL2上的Ubuntu,因此请注意位置可能会有所不同。问题出在npm缓存了一个全局安装的create-react-app和npx,它是v4.0.0,但当你使用npm view create-react-app
时并不显示。
如果你找到自己的npm缓存,对我来说它位于~/.npm/_npx/
文件夹中,你会发现所有你以前使用npx进行全局安装的哈希名称文件夹。
如果你查看每个文件夹,例如使用cat [hash]/package.json
,并记录包含create-react-app的任何哈希值。现在手动编辑package.json文件,将create-react-app的版本提升到4.0.1
,然后使用rm -rf [hash]/node_modules/create-react-app
从节点模块中删除它。
npx create-react-app my-app
,它会像平常一样提示您安装 'create-react-app',然后正常工作,此时npx将缓存正确的版本,因此您不会再遇到这个问题。您可以使用任何版本的node和npm。npm update npx
以解决问题。npx create-react-app "您喜欢的项目名称"
来创建您的React项目。我没有全局安装create-react-app,我只是执行了npm uninstall -g create-react-app
,然后执行了npm install create-react-app
yarn add create-react-app
3. 运行命令yarn run create-react-app myapp
use this :
npm install create-react-app
npm install create-react-app
是无效的。只需运行npx create-react-app my-app
即可创建一个新的React应用程序。 - ATYB这对我有效
npm uninstall -g create-react-app
那么
npm install -g create-react-app