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

Bel*_*lal 2 node.js npm reactjs create-react-app yarnpkg

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

我的环境信息是:

节点:v8.12.0

NPM:6.4.1

纱:1.10.1

作业系统: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.
Run Code Online (Sandbox Code Playgroud)

小智 9

我通过删除.yarnrc文件解决了这个问题C:\Users\yourUserName\


Ben*_*ith 7

当我使用yarn而不是npm时,一旦运行:

yarn cache clean
Run Code Online (Sandbox Code Playgroud)

然后再调用:

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

工作了。


Dek*_*eke 6

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

安装最新版本的node,npm和yarn。

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


Bel*_*lal 6

去掉.npmrcfromC:\Users\you\.npmrc也可以解决问题。


小智 5

我遇到了同样的问题,然后我尝试了以下命令,它解决了我的问题

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

上面的命令没有解决您的问题,请尝试下面的命令。

npm init -y
npx create-react-app your-app-name
Run Code Online (Sandbox Code Playgroud)