创建 React App 未安装,显示错误并中止安装

Create React App not installing, showing an error and aborting installation

我重新安装了 Node.js 和 Yarn。现在我收到这个错误。

我的环境信息是:

Node: v8.12.0

NPM: 6.4.1

Yarn: 1.10.1

OS: Windows 10

PS C:\Users\mdbel\Desktop\Project\redux> npx create-react-app learnredux

Creating a new React app in C:\Users\mdbel\Desktop\Project\redux\learnredux.

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

yarn add v1.10.1
[1/4] Resolving packages...
[2/4] Fetching packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.1.tgz: Request failed \"404 Not Found\"".
info If you think this is a bug, please open a bug report with the information provided in "C:\Users\mdbel\Desktop\Project\redux\learnredux\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

Aborting installation.
  yarnpkg add --exact react react-dom react-scripts --cwd C:\Users\mdbel\Desktop\Project\redux\learnredux has failed.

Deleting generated file... package.json
Deleting generated file... yarn.lock
Done.

我在使用 npx 时遇到了同样的问题,并且能够通过以下步骤解决此问题:

  • 升级到最新的 yarn 版本:$ npm i @yarn@latest
  • 删除 node_modules 文件夹
  • 删除 yarn.lock(如果存在)。
  • 从您的用户文件夹中删除 .npmrc。

如果问题仍然存在,您可以改用 yarn 命令:$ yarn create react-app learnredux

yarn create 在 Yarn 0.25+

中可用

我遇到了同样的问题并通过以下方式解决了:

正在安装最新版本的节点、npm 和 yarn。

npm install -g npm@latest
nvm install node
npm install -g yarn

nvm 安装 Node.js,npm 管理包。

我通过从 C:\Users\yourUserName\

中删除 .yarnrc 文件解决了这个问题

更新到 yarn 的最新稳定版本并删除 AppData 文件夹中的 yarn 缓存文件夹已解决我的问题 C:\Users\test\AppData\Local\Yarn

我在 Mac 上遇到了同样的错误。

我刚刚从 Node.js 网站重新下载了安装程序。这应该重新安装所有依赖项并确保所有路径都有效。

https://nodejs.org/en/download/

通过运行清理纱线缓存后:

yarn cache clean

然后后续调用:

npx create-react-app your-app

会起作用。

我还通过从

安装最新版本的节点解决了我的问题

https://nodejs.org/en/download/

然后我 运行 下面的命令

npm install -g create-react-app

在终端 如果您已经在文件夹中,则后跟 "create-react-app " 或 "create-react-app ."。

我遇到了同样的问题然后我尝试了下面的命令并解决了我的问题

npm cache clean --force

以上命令未能解决您的问题,请尝试以下命令。

npm init -y
npx create-react-app your-app-name

C:\Users\you\.npmrc中删除.npmrc也可以解决问题。

试试这个!

npm install -g npm@latest  

npm install node


npm install -g yarn


npx create-react-app appname

cd firstapp

yarn start

将节点模块更新到适合我的版本 13.12.0

https://nodejs.org/es/download/current/

是的,我有同样的问题,但在卸载 yarn 并使用最新版本更新节点后我无法解决。

此外,请确保您已安装

npm i -g create-react-app

更新包后。

同时清理缓存以消除错误,这肯定有效

这可能有助于 Linux 操作系统

sudo npm install -g npm@latest
npm install node
npm init
npm install -g yarn
yarn cache clean
npx create-react-app my-app

windows 用户的最佳方法是更新您的 yarn 如果你使用 npx 并得到错误而不是更新纱线然后使用 npx 我在 windows 8.1 中有同样的错误,然后我更新了 yarn 并解决了我的问题

Npm I yarn@latest
npx creat-react-app  app name

我遇到了同样的问题。这似乎是在 npmnode 安装被破坏时发生的。但是,有时清除缓存不起作用。我不仅要卸载系统上的 delete/purge 所有 npmnode 文件,还要重新安装它们。

删除节点和npm

sudo rm -rf /usr/local/lib/node_modules
sudo rm -rf ~/.npm

sudo apt remove --purge npm
sudo apt remove --purge node
sudo apt remove --purge nodejs

检查 npm 和节点是否被 运行 删除:which nodewhich npm 如果您仍然看到一些文件夹,请尝试使用以下方法删除它们:

sudo apt-get remove nodejs
sudo apt-get remove npm

更新系统,以防万一

sudo apt-get update

安装node和npm

sudo apt-get install nodejs
sudo apt-get install npm

检查安装

npm -v
node -v

注意:此处的步骤涉及删除现有模块并将其重新放回。我还必须使用 程序和功能 (对于 Windows)手动卸载 nodejs。

我不小心隐藏了 .yarnrc 文件,这导致了问题。

我遇到了同样的问题。您可以使用 npm 代替纱线来创建应用程序。只需添加 --use-npm 标志即可:

npx create-react-app app --use-npm

将节点重新安装到最新版本对我有用。

https://nodejs.org/en/download/