[英]When I create react native project it's give me error
提示:本站为国内最大中英文翻译问答网站,提供中英文对照查看,鼠标放在中文字句上可显示英文原文。
我的节点和本机版本
react-native -v : 2.0.1
node -v : v16.16.0
运行 cmd
npx react-native init Loan --version 0.68.2
or
npx react-native init Loan
它给我这样的错误
C:\Users\dp312>npx react-native init Loan --version 0.68.2 npm WARN config global `--global`, `--local` are deprecated. Use `--location-global` instead.
This will walk you through creating a new React Native project in C:\Users\dp312\Loan
'yarn' is not recognized as an internal or external command,
operable program or batch file. Installing react-native@0.68.2...
Consider installing yarn to make this faster: https://yarnpkg.com
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead. 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/react-native: 10976: error:1408F119:SSL routines: ss13_get_record: decryption failed or bad rec ord mac:c:\ws\deps\openssl\openssl\ssl\record\ss13_record.c:677: npm ERR!
npm ERR! A complete log of this run can be found in:
npm ERR!
C:\Users\dp312\AppData\Local\npm-cache\_logs\2023-02-01T12_48_16_254Z-debug-0.log
Error: Command failed: npm install --save --save-exact react-native@0.68.2
at checkExecSyncError (node: child_process:828:11)
at execSync (node: child_process: 899:15) at run (C:\Users\dp312\AppData\Roaming\npm\node_modules\react-native-cli\index.js:294:5)
at createProject (C:\Users\dp312\AppData\Roaming\npm\node_modules\react-native-cli\index.js:249:3)
at init (C:\Users\dp312\AppData\Roaming\npm\node_modules\react-native-cli\index.js:200:5) at Object.<anonymous> (C:\Users\dp312\AppData\Roaming\npm\node_modules\react-native-cli\index.js:153:7)
at Module._compile (node:internal/modules/cjs/loader: 1105:14)
at Object.Module._extensions..js (node: internal/modules/cjs/loader: 1159:10)
at Module.load (node:internal/modules/cjs/loader: 981:32) {
status: 1,
signal: null,
output: null, null, null ],
pid: 7772,
stdout: null,
stderr: null
} Command `npm install --save --save-exact react-native@0.68.2` failed.
C:\Users\dp312>
或者当我尝试使用 npm 在项目中安装任何 lib 时它也给我错误但是当我运行 yarn 它安装成功
任何人都可以给我解决方案以及为什么会出现此错误
我只是在出现此错误后重置我的电脑,但在重置电脑之前它工作正常我不知道为什么会出现此错误。
尝试清除缓存并重新安装
npm cache clear --force
npm install
或者
npm cache verify
npm install
似乎是 npm 包的反复出现的问题: npm ERR:尝试获取 http 时响应主体无效。//registry.npmjs:org/accepts:sha 的完整性验证失败
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.