javascript - React Native cannot npx init project, cannot find module 报错

标签 javascript node.js reactjs react-native npx

npx react-native 初始化 MyApp

√ Downloading template × Copying template error Error: Cannot find module 'C:\Users\%%%%\AppData\Local\Temp\rncli-init-template-rVvcjE\node_modules\react-native\template.config' Require stack: - C:\Users\%%%%%\node_modules\react-native\node_modules@react-native-community\cli\build\commands\init\template.js - C:\Users\%%%%%\node_modules\react-native\node_modules@react-native-community\cli\build\commands\init\init.js - C:\Users\%%%%%\node_modules\react-native\node_modules@react-native-community\cli\build\commands\init\index.js - C:\Users\%%%%%\node_modules\react-native\node_modules@react-native-community\cli\build\commands\index.js - C:\Users\%%%%%\node_modules\react-native\node_modules@react-native-community\cli\build\index.js - C:\Users\%%%%%\node_modules\react-native\cli.js

npx react-native 信息

info Fetching system and libraries information... System: OS: Windows 10 10.0.18363 CPU: (8) x64 AMD Ryzen 5 2500U with Radeon Vega Mobile Gfx Memory: 3.88 GB / 6.80 GB Binaries: Node: 12.13.1 - C:\Program Files\nodejs\node.EXE npm: 6.12.1 - C:\Program Files\nodejs\npm.CMD SDKs: Android SDK: API Levels: 21, 22, 23, 24, 25, 26, 27, 28, 29 Build Tools: 28.0.3, 29.0.2 IDEs: Android Studio: Version 3.5.0.0 AI-191.8026.42.35.5977832 npmPackages: react-native: 0.61.5 => 0.61.5

为了避免不必要的响应 npm uninstall react-native-cli -g 已经完成。

上述文件路径中的 rncli-init-template-rVvcjE 甚至不存在,我不确定为什么。谢谢,大家提前帮助我是堆栈溢出的新手,到目前为止我只是在竞争性编程。对算法不陌生,但对于跨平台开发框架,我是个新手。

最佳答案

尝试用 yarn 初始化。 Yarn 的性能优于 npm ( link July 2019 )。

先安装yarn

npm install -g yarn

安装 react-native-cli。如果不起作用,请尝试使用 sudo。

yarn global add react-native-cli

创建你的项目

react-native init myapp

Related post

关于javascript - React Native cannot npx init project, cannot find module 报错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59254512/

相关文章:

javascript - 重新排序时在 React 归零滚动位置 A 中列出(在 Chrome 72.0 中,在 Mac 上)

javascript - 我无法使用 onclick 来工作

javascript - 使用 Javascript/jQUery 测量 HTML 中的字符串长度

javascript - 使用node.js接收POST请求

android - SocketIO的回调功能是SocketIO独有的功能吗?如果是这样,标题是如何形成的?

reactjs - 我需要访问一个单击按钮后弹出的新窗口

javascript - 如何将 Javascript 变量值显示到 HTML href 标签

javascript - 表单中的 Angular 动态场未显示在 View 中

node.js - npm开始报错

javascript - 当 prop 依赖项更改时,React useEffect Hook 不会触发