npm 我在创建react应用程序时遇到问题

suzh9iv8  于 2023-01-05  发布在  React
关注(0)|答案(1)|浏览(264)

我试图创建一个新的react项目,但遇到了以前从未遇到过的错误,我尝试了npm cache clean --force它显示**npm WARN using --force建议的保护已禁用。**所以我尝试了以下操作
npm缓存验证它响应了

it Cache verified and compressed (~\AppData\Local\npm-cache\_cacache)
Content verified: 0 (0 bytes)
Index entries: 0
Finished in 0.013s

但是我仍然不能使用命令npx create-react-app projectName创建react应用程序
它只会回应

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

npm ERR! code FETCH_ERROR
npm ERR! errno FETCH_ERROR
npm ERR! invalid json response body at https://registry.npmjs.org/html-entities reason: Invalid response body while trying to fetch https://registry.npmjs.org/html-entities: Socket timeout

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\u4\AppData\Local\npm-cache\_logs\2023-01-04T11_43_21_180Z-debug-0.log

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

Deleting generated file... package.json
Deleting travel/ from C:\Users\u4\Desktop\code
Done.

我更新了我的节点,以为可能是问题,但仍然没有改变帮助!!

euoag5mw

euoag5mw1#

所以我找到了我的问题的来源。首先我运行npm -g列表并且它只有npm没有create-react-app所以你需要安装它使用npm安装-g create-react-app。检查它通过运行npm -g列表如果成功安装create-react-app将是他们的。现在你可以运行npx create-react-app projctname with out a problem.

相关问题