React-Native:main.jsbundle不存在。这必须是带有“无法将对象转换为原始值”的错误

时间:2018-10-01 05:20:08

标签: ios react-native

我的项目信息

React Native Environment Info:
System:
  OS: macOS High Sierra 10.13.6
  CPU: x64 Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
  Memory: 241.64 MB / 8.00 GB
  Shell: 3.2.57 - /bin/bash
Binaries:
    Node: 8.11.3 - /usr/local/bin/node
    Yarn: 1.7.0 - /usr/local/bin/yarn
    npm: 6.2.0 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
    iOS SDK:
        Platforms: iOS 12.0, macOS 10.14, tvOS 12.0, watchOS 5.0
    Android SDK:
        Build Tools: 21.1.2, 22.0.1, 23.0.1, 23.0.2, 23.0.3, 25.0.0, 25.0.2, 25.0.3, 26.0.1, 26.0.2, 26.0.3, 27.0.3, 28.0.2
    API Levels: 23, 24, 25, 26, 27
IDEs:
    Android Studio: 3.0 AI-171.4408382
    Xcode: 10.0/10A255 - /usr/bin/xcodebuild
npmPackages:
    react: 16.4.1 => 16.4.1 
    react-native: 0.56.0 => 0.56.0 
npmGlobalPackages:
    create-react-native-app: 1.0.0
    react-native-camera: 0.9.0
    react-native-cli: 2.0.1
    react-native-git-upgrade: 0.2.7
    react-native-maps: 0.15.2
    react-native-vector-icons: 4.0.0

Dev 运行项目运行正常,但是以 Release 运行会产生以下错误。

warning: the transform cache was reset.
Loading dependency graph, done.

/Users/macintoshhd/Documents/TGS/mow/node_modules/rx/dist/rx.all.js: Cannot convert object to primitive value

+ [[ false != true ]]
+ [[ ! -f /Users/macintoshhd/Library/Developer/Xcode/DerivedData/mow-ekmdxdpkhrpqmmdbccixjzdqelmg/Build/Products/Release-iphoneos/mow.app/main.jsbundle ]]
+ echo 'error: File /Users/macintoshhd/Library/Developer/Xcode/DerivedData/mow-ekmdxdpkhrpqmmdbccixjzdqelmg/Build/Products/Release-iphoneos/mow.app/main.jsbundle does not exist. This must be a bug with'

我尝试将项目与--dev=false手动捆绑

react-native bundle --entry-file='index.js' --bundle-output='./ios/main.jsbundle' --dev=false --platform='ios' --assets-dest='./ios'

我得到了这个错误输出

  

扫描文件夹中的/ Users / macintoshhd / Documents / myproject / node_modules中的符号链接(41毫秒)   扫描文件夹中的/ Users / macintoshhd / Documents / myproject / node_modules中的符号链接(29毫秒)   加载依赖图,完成。

     

/Users/macintoshhd/Documents/myproject/node_modules/rx/dist/rx.all.js:无法将对象转换为原始值

--dev=false更改为--dev=true,则这些输出将成功完成

react-native bundle --entry-file='index.js' --bundle-output='./ios/main.jsbundle' --dev=true --platform='ios' --assets-dest='./ios'
  

在/ Users / macintoshhd / Documents / TGS / mow / node_modules中扫描文件夹中的符号链接(15ms)
  在/ Users / macintoshhd / Documents / TGS / mow / node_modules中扫描文件夹中的符号链接(17ms)
  加载依赖关系图已完成。
  bundle:将bundle输出写入:./ios/mow/main.jsbundle
  bundle:完成写bundle输出
  捆绑软件:复制31个资产文件
  捆绑包:完成复制资产

我尝试了
-清理并重建
-删除node_modules并重新安装
-清理派生文件夹,重新启动Xcode, 但他们都没有解决问题。

这似乎是主要问题。

  

/Users/macintoshhd/Documents/TGS/mow/node_modules/rx/dist/rx.all.js:无法将对象转换为原始值

您有什么建议,请帮忙。 谢谢!

2 个答案:

答案 0 :(得分:2)

我花了几天时间通过注释所有代码并逐一注释掉node_modules/rx/dist/rx.all.js: Cannot convert object to primitive value错误的原因。

问题是,当我在自动补全弹出窗口后偶然按下Enter键时,VS Code会自动导入未知库。是

import { AsyncSubject } from 'rx';

删除导入语句后,我以发布模式成功构建了项目。

以Dev模式运行时,此类错误不会引发异常:(,为Release进行构建时除外。

答案 1 :(得分:0)

我想问题出在图书馆本身。请检查一下有关https://github.com/bberak/react-native-game-engine/issues/10

的相关问题