RN Expo 问题 - 安装 JavaScript 依赖项时出现错误。检查你的 npm 日志。继续初始化应用程序

Rif*_*fat 8 npm react-native expo

我正在使用react nativeExpo。我无法构建新的应用程序,因为在使用后expo init appName它显示以下错误。\n以下是完整消息:

\n
 Using npm to install packages. You can pass --yarn to use Yarn instead.\n\n\xe2\x88\x9a Downloaded and extracted project files.\n\xc3\x97 Something when wrong installing JavaScript dependencies. Check your npm logs. Continuing to initialize the app.\n\n\xe2\x9c\x85 Your project is ready!\n\nTo run your project, navigate to the directory and run one of the following npm commands.\n\n- cd Scanner\n- npm start # you can open iOS, Android, or web from here, or run them directly with the commands below.\n- npm run android\n- npm run ios # requires an iOS device or macOS for access to an iOS simulator\n- npm run web\n
Run Code Online (Sandbox Code Playgroud)\n

我多次尝试创建一个空白项目,还尝试npm install安装失败/未下载的库并在失败后继续,但它显示了另一个错误:

\n
npm ERR! code Z_BUF_ERROR\nnpm ERR! errno -5\nnpm ERR! zlib: unexpected end of file\n
Run Code Online (Sandbox Code Playgroud)\n

还尝试npm cache verify显示缓存正常Content verified: 3562 (252580364 bytes)

\n

那么,我该如何解决这个问题呢?

\n

PRA*_*PUT 10

如果您在早期安装中犯了任何错误,与 npm 安装相关的问题很常见,但可以避免。了解有关 npm 树的更多信息。

对我有用的步骤是:

  1. npm 缓存清理 --force

  2. npm 缓存验证

  3. npm -g 卸载 expo-cli --save

  4. npm 安装 expo-cli --global

  5. expo 初始化应用程序名称

  6. cd 应用程序名称

  7. npm 启动

如果在 Windows 和根目录中工作,请始终以管理员身份运行。


小智 0

我也遇到了这个问题,最后发现是react native cli\xef\xbc\x8c的问题,我安装了最新版本的react native cli\xef\xbc\x8cExpo就恢复正常了

\n