运行 npm install create-react-app 时出现错误 404

IT技术 node.js reactjs npm
2021-04-24 21:12:23

404运行时出错npm install create-react-appnpm install -g npm@latest.

日志:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'install',
1 verbose cli   'create-react-app' ]
2 info using npm@5.6.0
3 info using node@v8.11.3
4 verbose npm-session 1f3eafc1b2f09e93
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 http fetch GET 404 http://registry.npmjs.org/create-react-app 66ms
8 silly fetchPackageMetaData error for create-react-app@latest 404 Not Found: create-react-app@latest
9 verbose stack Error: 404 Not Found: create-react-app@latest
9 verbose stack     at fetch.then.res (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\lib\fetchers\registry\fetch.js:42:19)
9 verbose stack     at tryCatcher (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\util.js:16:23)
9 verbose stack     at Promise._settlePromiseFromHandler (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:512:31)
9 verbose stack     at Promise._settlePromise (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:569:18)
9 verbose stack     at Promise._settlePromise0 (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:614:10)
9 verbose stack     at Promise._settlePromises (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:693:18)
9 verbose stack     at Async._drainQueue (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\async.js:133:16)
9 verbose stack     at Async._drainQueues (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\async.js:143:10)
9 verbose stack     at Immediate.Async.drainQueues (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\async.js:17:14)
9 verbose stack     at runCallback (timers.js:810:20)
9 verbose stack     at tryOnImmediate (timers.js:768:5)
9 verbose stack     at processImmediate [as _immediateCallback] (timers.js:745:5)
10 verbose cwd M:\Projects\TestApps\ReactApp
11 verbose Windows_NT 6.1.7601
12 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "create-react-app"
13 verbose node v8.11.3
14 verbose npm  v5.6.0
15 error code E404
16 error 404 Not Found: create-react-app@latest
17 verbose exit [ 1, true ]
4个回答

首先检查是否是代理问题

尝试使用另一个 Internet 连接安装该软件包

另一个原因

缺少存储库注册表

$ npm set registry https://registry.npmjs.org/

清理缓存

$ npm cache clean
$ npm rebuild

我的问题也一样,但是当我尝试以下命令时,效果很好

如果您以前create-react-app通过 全局安装npm install -g create-react-app,我建议您卸载软件包npm uninstall -g create-react-app以确保 npx 始终使用最新版本。

然后使用重新安装

npm install -g create-react-app

您已经全局安装了 npm create-react-app。你可以写

 npm init react-app *projectFolderName* 

它会工作得很好。

如果您使用 windows 1 以管理员身份运行 cmd,2 将此 url 'npm config set registry https://skimdb.npmjs.com/registry'放在 cmd 上,那么我遇到了差不多一个星期的相同问题,这是我的简单解决方案, 3 然后输入'npx create-react-app@latest YourProjectName '