- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我的项目信息
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'
我得到了这个错误输出
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
将 --dev=false
更改为 --dev=true
,这些输出表明 buid 成功
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
我试过了
- 清理和重建
- 删除 node_modules 并重新安装
- 清理 Derived 文件夹,重启 Xcode,但他们都没有解决问题。
这似乎是主要问题。
/Users/macintoshhd/Documents/TGS/mow/node_modules/rx/dist/rx.all.js: Cannot convert object to primitive value
您有什么建议,请帮忙。谢谢!
最佳答案
我花了几天的时间来找出 node_modules/rx/dist/rx.all.js: Cannot convert object to primitive value
错误的原因,方法是注释所有代码并一一取消注释。
问题是,当我在自动完成弹出窗口后巧合地按下 Enter 时,VS Code 会自动导入未知库。这是
import { AsyncSubject } from 'rx';
去掉import语句后,我在Release模式下成功构建了项目。
这种错误在以 Dev 模式运行时不会抛出异常 :(,为 Release 构建时除外。
关于ios - React-Native:main.jsbundle 不存在。这一定是 "Cannot convert object to primitive value"的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52584957/
我是一名优秀的程序员,十分优秀!