无法使用 create-react-app 设置react项目

IT技术 reactjs
2022-07-07 01:41:43

以下是运行命令后出现的错误

C:\Users\parde>npx create-react-app app

Creating a new React app in C:\Users\parde\app.

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

npm ERR! code ERR_SSL_DECRYPTION_FAILED_OR_BAD_RECORD_MAC
npm ERR! errno ERR_SSL_DECRYPTION_FAILED_OR_BAD_RECORD_MAC
npm ERR! Invalid response body while trying to fetch https://registry.npmjs.org/@babel%2fcore: 10552:error:1408F119:SSL routines:ssl3_get_record:decryption failed or bad record mac:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:677:
npm ERR!

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\parde\AppData\Local\npm-cache\_logs\2022-09-09T13_12_40_326Z-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 app/ from C:\Users\parde
Done.C:\Users\parde>npx create-react-app app

   

我试过了:

  1. 运行 npm cache clean --force
  2. 然后运行 ​​npx create-react-app (项目名称)
2个回答

这似乎是与网络相关的错误。看看这个线程尝试以下任何方法:

  1. 使用 VPN
  2. 在防火墙中允许 NodeJs
  3. 更新你的 npmnpm install --location=global
  4. 重新安装 NodeJs

他们在 NPM 存储库中遇到了一个与此相关的问题 似乎与 windows 防御者防火墙有关

https://github.com/nodejs/help/issues/3815