无法在 react native CLI 中运行 npx react-native init MyApp

Posted

技术标签:

【中文标题】无法在 react native CLI 中运行 npx react-native init MyApp【英文标题】:can not run npx react-native init MyApp in react native CLI 【发布时间】:2021-09-25 10:33:46 【问题描述】:

我尝试使用 npx react-native init Kick 制作一个新的 react native cli 应用程序,但一段时间后出现此错误

错误日志

Downloading template
error Error: Command failed: npm install --save --save-exact react-native@latest
npm ERR! code E404
npm ERR! 404 Object Not Found - GET https://skimdb.npmjs.com/registry/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz - not_found
npm ERR! 404
npm ERR! 404  'remove-trailing-separator@https://skimdb.npmjs.com/registry/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz' 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
pm 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\Acer\AppData\Local\npm-cache\_logs\2021-07-16T15_48_17_958Z-debug.log```

OS: Windows 10
SDK: android
npm: version 7.9.0

【问题讨论】:

【参考方案1】:

你可以试试

    更新 Node.js 在命令提示符下运行 npm cache clean 命令 (或) 以管理员身份在命令提示符下运行 reactive-native init(在 Windows 操作系统上)

【讨论】:

【参考方案2】:

这可能是因为您在开发设置时错过了一些步骤。 这是您可以设置环境的链接。

[https://reactnative.dev/docs/environment-setup][1]

只需按照说明正确运行应用程序即可。

【讨论】:

以上是关于无法在 react native CLI 中运行 npx react-native init MyApp的主要内容,如果未能解决你的问题,请参考以下文章

React Native - 当 react-native 版本 > 0.55 时,无法通过 react-native-cli 创建新项目

无法解析模块'./core/theming' React-native cli

什么是 react-native-cli 和 @react-native-community/cli?

设置 Wix/Detox - 运行他们的 react native 示例

react-native-cli运行项目及打包apk失败的解决过程

错误:EMFILE:打开的文件太多 - React Native CLI