Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React-Native: main.jsbundle does not exist. This must be a bug with "Cannot convert object to primitive value"

My Project Info

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

Running the project as Dev is working fine, but running as Release produce the following error.

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'

I tried to manually bundle the project with --dev=false

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

and I got this error output

Scanning folders for symlinks in /Users/macintoshhd/Documents/myproject/node_modules (41ms) Scanning folders for symlinks in /Users/macintoshhd/Documents/myproject/node_modules (29ms) Loading dependency graph, done.

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

Changing --dev=false to --dev=true, the buid success with these output

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

Scanning folders for symlinks in /Users/macintoshhd/Documents/TGS/mow/node_modules (15ms)
Scanning folders for symlinks in /Users/macintoshhd/Documents/TGS/mow/node_modules (17ms)
Loading dependency graph, done.
bundle: Writing bundle output to: ./ios/mow/main.jsbundle
bundle: Done writing bundle output
bundle: Copying 31 asset files
bundle: Done copying assets

I have tried
- clean and rebuild
- remove node_modules and reinstall
- clean Derived folder, restart Xcode, but none of them solve the issue.

It seems like this is the main issues.

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

Would you have any suggestion, please kindly help. Thanks!

like image 297
Ponleu Avatar asked Oct 01 '18 05:10

Ponleu


1 Answers

I struggle a few days to figure the cause of node_modules/rx/dist/rx.all.js: Cannot convert object to primitive value error by comment all code and uncomment one by one.

The thing is that VS Code auto import unknown library when I coincidently press Enter after autocompletion popup. It is

import { AsyncSubject } from 'rx';

After removing the import statement, I successfully build the project in Release mode.

This kind of error does not throw exception when running as Dev mode :(, except while building for Release.

like image 168
Ponleu Avatar answered Nov 07 '22 17:11

Ponleu