【问题标题】:React native packager fails to create jsbundleReact 本机打包程序无法创建 jsbundle
【发布时间】:2018-02-14 08:38:24
【问题描述】:

我刚刚将 react-native 版本从 0.30 升级到 0.48.1,我遇到了一个奇怪的问题。 我修复了我正在使用的库的所有对等依赖项。然后运行命令,

react-native 开始

运行上述命令会启动打包程序。现在,当我点击下面的 url 生成 jsbundle 时, http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false

我遇到了错误,

"message":"Ambiguous resolution: module '$PROJ_ROOT_DIR/index.android.js' tries to require 'react-native', but there are several files providing this module. You can delete or fix them: 
$PROJ_ROOT_DIR/node_modules/jest-react-native/node_modules/react-native/package.json
$PROJ_ROOT_DIR/node_modules/react-native/package.json"

$PROJ_ROOT_DIR 是我的项目目录路径。

我的设置中没有任何“$PROJ_ROOT_DIR/node_modules/jest-react-native/node_modules/”目录。 我尝试删除 node_modules 目录,然后运行 ​​npm install。但没有任何改变。

我也试过,通过运行命令清除打包缓存,

ls -l $TMPDIR/react-*

但什么也没发生。

有没有人遇到过类似的问题?有什么建议?

提前致谢!

【问题讨论】:

  • 请在此处发布您的 package.json 文件。
  • 而且为什么这个命令react-native start?
  • 我的错。是的,这是一个缓存问题。 npm start -- --reset-cache 解决了这个问题。 packager.sh 文件位置更改为 RN 0.48,因此我的设置无法找到 packager.sh 文件并且 npm start 无法正常工作。我假设react-native startnpm start 可能相同。但他们不是。
  • 我一直在使用react-native start -- --reset-cache,但没有任何反应。浪费了几个小时。 :(
  • 那么它是否有效?

标签: react-native


【解决方案1】:

如果其他人面临同样的类似问题,使用以下命令清除缓存对我有用。

npm start -- --reset-cache

我正在尝试react-native start -- --reset-cache 命令,它什么都不做(我的错。)。

【讨论】:

猜你喜欢
  • 2018-11-05
  • 2018-01-11
  • 1970-01-01
  • 2019-10-03
  • 1970-01-01
  • 2019-05-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多