开发者问题收集

错误:create-react-app 中止安装

2020-02-12
2142

根据 Reactjs 文档:

You’ll need to have Node >= 8.10 and npm >= 5.6 on your machine. To create a project, run:

npx create-react-app my-app

我的环境满足它:

AymanMorsy@DESKTOP-6V4567D MINGW64 /g/reactprojects
$ node --version && npm --version 👈👈
v12.16.0 👈👈
6.13.4 👈👈

AymanMorsy@DESKTOP-6V4567D MINGW64 /g/reactprojects
$ npx create-react-app my-app
npx: installed 99 in 17.908s

Creating a new React app in G:\reactprojects\my-app.

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

npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz
npm ERR! 404
npm ERR! 404  'error-ex@^1.3.1' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 It was specified as a dependency of 'parse-json'
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\AymanMorsy\AppData\Roaming\npm-cache\_logs\2020-02-12T21_29_30_123Z-debug.log

Aborting installation. 🚨🚨🚨
  npm install --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.

Deleting generated file... package.json
Deleting my-app/ from G:\reactprojects
Done.

我尝试了 Create React App 未安装,显示错误并中止安装 的解决方案>

最后我格式化了 C 并安装了 Windows10 的最新更新,仍然看到同样的问题

编辑: npm 配置的输出

$ npm config list
; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.13.4 node/v12.16.0 win32 x64"

; builtin config undefined
prefix = "C:\\Users\\AymanMorsy\\AppData\\Roaming\\npm"

; node bin location = C:\Program Files\nodejs\node.exe
; cwd = G:\reactprojects
; HOME = C:\Users\AymanMorsy
; "npm config ls -l" to show all defaults.
列表
3个回答

看起来 https://registry.npmjs.org/error-ex 在某些地区不可用

很快就会恢复

Anas M.I
2020-02-13

以下解决方案⤵ 安装 Scoop 然后安装 yarn,然后执行 yarn create-react-app myapp 100% 肯定有效

krishna kakade
2020-08-07

就我而言,防病毒软件阻止了某些模块的访问。关闭它,并安装了 yarn。工作正常

  1. 暂时停止防病毒软件。

  2. npm install -g yarn

  3. yarn global add create-react-app

  4. npx create-react-app my-app

  5. 启动防病毒软件

虽然我觉得 yarn 不是解决我这个问题的必需品 - 我更喜欢 yarn。 希望这对某些人有帮助。

A.K
2020-12-12