我执行命令react-native run-ios
。
将显示无法加载捆绑软件。
我试图....
删除node_modules文件夹-rm -rf node_modules
&& npm install
重置打包程序缓存-rm -fr $TMPDIR/react-*
或node_modules/react-native/packager/packager.sh --reset-cache
清晰的守望者手表-watchman watch-del-all
但尚未解决的问题。
请查看错误屏幕截图。
谢谢。
React Native Environment Info:
System:
OS: macOS High Sierra 10.13.4
CPU: x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
Memory: 4.97 GB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.5.0 - /usr/local/bin/node
npm: 6.1.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 11.4, macOS 10.13, tvOS 11.4, watchOS 4.3
IDEs:
Android Studio: 3.1 AI-173.4819257
Xcode: 9.4.1/9F2000 - /usr/bin/xcodebuild
npmPackages:
react: ^16.3.1 => 16.3.1
react-native: ^0.56.0 => 0.56.0
npmGlobalPackages:
react-native-cli: 2.0.1
package.json
{
"name": "projactname",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"axios": "^0.18.0",
"babel-preset-react-native-stage-0": "^1.0.1",
"crypto-js": "^3.1.9-1",
"immutable": "^3.8.2",
"key-mirror": "^1.0.1",
"moment": "^2.22.0",
"native-base": "^2.7.2",
"npm": "^5.8.0",
"pretty-format": "^22.4.3",
"react": "^16.3.1",
"react-native": "^0.56.0",
"react-native-ble-manager": "^6.3.1",
"react-native-calendars": "^1.18.2",
"react-native-camera": "^1.1.4",
"react-native-carousel-pager": "^1.4.2",
"react-native-datepicker": "^1.7.2",
"react-native-i18n": "^2.0.12",
"react-native-image-gallery": "^2.1.5",
"react-native-indicators": "^0.12.0",
"react-native-keyboard-aware-scroll-view": "^0.5.0",
"react-native-payments": "^0.4.0",
"react-native-phone-call": "^1.0.4",
"react-native-qrcode-scanner": "^1.0.1",
"react-native-qrcode-svg": "^5.0.6",
"react-native-simple-dialogs": "^0.3.1",
"react-native-sqlite-storage": "^3.3.6",
"react-native-status-bar-height": "^2.0.0",
"react-native-svg": "^6.3.1",
"react-native-unique-id": "^1.0.4",
"react-navigation": "^1.5.11",
"react-redux": "^5.0.7",
"redux": "^3.7.2",
"redux-axios-middleware": "^4.0.0",
"redux-logger": "^3.0.6",
"redux-observable": "^0.18.0",
"redux-promise-middleware": "^5.1.1",
"rn-splash-screen": "^5.2.0",
"rxjs": "^5.5.10"
},
"devDependencies": {
"babel-jest": "22.4.3",
"babel-preset-es2017": "^6.24.1",
"babel-preset-react-native": "^4.0.0",
"eslint": "^4.19.1",
"flow-bin": "^0.71.0",
"jest": "22.4.3",
"react-test-renderer": "16.3.1",
"redux-devtools": "^3.4.1"
},
"jest": {
"preset": "react-native"
}
}
更新:
我尝试删除node_modules并将项目移至桌面。
还是这个问题。
Metro Bundler-lanuchPackager.command
Loading dependency graph, done.
error: bundling failed: Error: Plugin/Preset files are not allowed to export objects, only functions. In /Users/myname/Desktop/myapp/node_modules/babel-preset-react-native-stage-0/index.js
at createDescriptor (/Users/myname/Desktop/myapp/node_modules/@babel/core/lib/config/config-descriptors.js:162:11)
at items.map (/Users/myname/Desktop/myapp/node_modules/@babel/core/lib/config/config-descriptors.js:87:50)
at Array.map (<anonymous>)
at createDescriptors (/Users/myname/Desktop/myapp/node_modules/@babel/core/lib/config/config-descriptors.js:87:29)
at createPresetDescriptors (/Users/myname/Desktop/myapp/node_modules/@babel/core/lib/config/config-descriptors.js:79:10)
at presets (/Users/myname/Desktop/myapp/node_modules/@babel/core/lib/config/config-descriptors.js:61:19)
at presets (/Users/myname/Desktop/myapp/node_modules/@babel/core/lib/config/config-descriptors.js:51:25)
at mergeChainOpts (/Users/myname/Desktop/myapp/node_modules/@babel/core/lib/config/config-chain.js:308:26)
at /Users/myname/Desktop/myapp/node_modules/@babel/core/lib/config/config-chain.js:271:7
答案 0 :(得分:0)
问题已解决。我已更改 .babelrc :
"presets": ["react-native-stage-0"]
到
"presets": ["react-native"]
答案 1 :(得分:0)
清洁Metro Bundler:rm -fr $ TMPDIR / metro *我不确定地铁文件在Windows中的确切位置,但可以搜索并删除它们。您也可以尝试更改项目名称,并在package.json中提高项目版本
"name": "projactname",
"version": "0.0.1",
如果到目前为止,您在执行所有步骤后仍然遇到相同的问题,则很可能是应用程序逻辑中的某个问题。通过在App.js中创建某种Hello World程序(而不是加载项目文件)来进行测试。在项目文件树中重复此操作,直到找到问题为止。