React Native:节点类型SpreadProperty已重命名为SpreadElement

时间:2019-06-13 20:24:22

标签: ios reactjs react-native

我最近从React Native 0.53.3升级到React Native 0.59.9,我的应用程序不断在模拟器内部崩溃。它将显示启动屏幕,然后在debugger-ui中什么都没有崩溃,除了:

  

WebSocket连接到   'ws:// localhost:8081 / debugger-proxy?role = debugger&name = Chrome'失败:   建立连接错误:net :: ERR_CONNECTION_REFUSED

我使用react-native run-ios运行它,但是构建在那里成功,因此没有错误消息。当我尝试在打开Xcode的同时打开应用程序时,确实提到了无法找到.jsbundle文件并且在Xcode内部的错误,我确实有一个main.jsbundle红色,表示它丢失了

因此找到本文后: https://medium.com/the-react-native-log/first-time-deploying-with-react-native-f524eb3e705d#59ee

我尝试通过使用引用该脚本的npm run build:ios脚本进行跟踪:

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

但是当我运行它时,出现此错误:

Loading dependency graph, done.
transform[stderr]: Trace: The node type SpreadProperty has been renamed to SpreadElement
transform[stderr]:     at Object.isSpreadProperty (/Users/danale/Projects/engage-application.mobile/node_modules/@babel/types/lib/validators/generated/index.js:4304:11)
transform[stderr]:     at hasSpread (/Users/danale/Projects/engage-application.mobile/node_modules/babel-plugin-transform-object-rest-spread/lib/index.js:38:13)
transform[stderr]:     at PluginPass.ObjectExpression (/Users/danale/Projects/engage-application.mobile/node_modules/babel-plugin-transform-object-rest-spread/lib/index.js:234:14)
transform[stderr]:     at newFn (/Users/danale/Projects/engage-application.mobile/node_modules/@babel/traverse/lib/visitors.js:193:21)
transform[stderr]:     at NodePath._call (/Users/danale/Projects/engage-application.mobile/node_modules/@babel/traverse/lib/path/context.js:53:20)
transform[stderr]:     at NodePath.call (/Users/danale/Projects/engage-application.mobile/node_modules/@babel/traverse/lib/path/context.js:40:17)
transform[stderr]:     at NodePath.visit (/Users/danale/Projects/engage-application.mobile/node_modules/@babel/traverse/lib/path/context.js:88:12)
transform[stderr]:     at TraversalContext.visitQueue (/Users/danale/Projects/engage-application.mobile/node_modules/@babel/traverse/lib/context.js:118:16)
transform[stderr]:     at TraversalContext.visitSingle (/Users/danale/Projects/engage-application.mobile/node_modules/@babel/traverse/lib/context.js:90:19)
transform[stderr]:     at TraversalContext.visit (/Users/danale/Projects/engage-application.mobile/node_modules/@babel/traverse/lib/context.js:146:19)
error node_modules/react-native-keyboard-manager/index.js: Cannot read property 'bindings' of null. Run CLI with --verbose flag for more details.

与该错误有关的唯一信息是以下信息:

https://stackoverflow.com/questions/53326986/trace-the-node-type-spreadproperty-has-been-renamed-to-spreadelement-at-object

它并不真正适用于我的情况。

问题似乎出在@babel内的node_modules库中,我曾尝试做过一个rm -rf node_modules,但这并不能解决。

有人可以确认这些开发依赖项之一是否不再支持该项目的当前版本?

"devDependencies": {
    "async": "2.6.0",
    "babel-cli": "6.24.1",
    "babel-eslint": "8.0.2",
    "babel-jest": "23.0.0",
    "babel-plugin-module-resolver": "3.0.0",
    "babel-preset-env": "1.4.0",
    "babel-preset-flow": "6.23.0",
    "babel-preset-react-native": "4.0.0",
    "babel-preset-stage-2": "6.24.1",
    "babel-watch": "2.0.6",

有人通过升级到React Native 0.59.9解决了类似的问题吗?

我了解到,在RN 0.49之后,我们使用index.js而不是index.ios.js,并且在创建模拟版本以尝试获得基准应用程序以弄清楚发生了什么时我进行了验证上。

我做了以下事情:

✗ mv index.ios.js index.js
➜  engage-application.mobile git:(feature/3.6.2_upgrade) ✗ rm index.android.js
➜  engage-application.mobile git:(feature/3.6.2_upgrade) ✗ react-native bundle --entry-file ./index.js --platform ios --bundle-output ios/main.jsbundle --verbose
Loading dependency graph, done.
transform[stderr]: Trace: The node type SpreadProperty has been renamed to SpreadElement
transform[stderr]:     at Object.isSpreadProperty (/Users/danale/Projects/engage-application.mobile/node_modules/@babel/types/lib/validators/generated/index.js:4304:11)
transform[stderr]:     at hasSpread (/Users/danale/Projects/engage-application.mobile/node_modules/babel-plugin-transform-object-rest-spread/lib/index.js:38:13)
transform[stderr]:     at PluginPass.ObjectExpression (/Users/danale/Projects/engage-application.mobile/node_modules/babel-plugin-transform-object-rest-spread/lib/index.js:234:14)
transform[stderr]:     at newFn (/Users/danale/Projects/engage-application.mobile/node_modules/@babel/traverse/lib/visitors.js:193:21)
transform[stderr]:     at NodePath._call (/Users/danale/Projects/engage-application.mobile/node_modules/@babel/traverse/lib/path/context.js:53:20)
transform[stderr]:     at NodePath.call (/Users/danale/Projects/engage-application.mobile/node_modules/@babel/traverse/lib/path/context.js:40:17)
transform[stderr]:     at NodePath.visit (/Users/danale/Projects/engage-application.mobile/node_modules/@babel/traverse/lib/path/context.js:88:12)
transform[stderr]:     at TraversalContext.visitQueue (/Users/danale/Projects/engage-application.mobile/node_modules/@babel/traverse/lib/context.js:118:16)
transform[stderr]:     at TraversalContext.visitSingle (/Users/danale/Projects/engage-application.mobile/node_modules/@babel/traverse/lib/context.js:90:19)
transform[stderr]:     at TraversalContext.visit (/Users/danale/Projects/engage-application.mobile/node_modules/@babel/traverse/lib/context.js:146:19)
error App.js: Cannot read property 'bindings' of null
debug TypeError: Cannot read property 'bindings' of null
    at Scope.moveBindingTo (/Users/danale/Projects/engage-application.mobile/node_modules/@babel/traverse/lib/scope/index.js:864:13)
    at BlockScoping.updateScopeInfo (/Users/danale/Projects/engage-application.mobile/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:364:17)

无论如何我仍然会遇到相同的错误。

1 个答案:

答案 0 :(得分:0)

实际上这里有两个独立的问题。

  

WebSocket连接到   'ws:// localhost:8081 / debugger-proxy?role = debugger&name = Chrome'失败:   建立连接错误:net :: ERR_CONNECTION_REFUSED

错误与端口8081已被使用的事实有关,因此我不得不完全杀死所有进程。

在Babel和一个或两个自定义软件包(主要是react-native-keyboard-managerreact-native-input-scroll-view)之间肯定存在一些依赖关系问题。我删除了这些,并改用了react-native的{​​{1}}。

然后我能够成功运行:

ScrollView

这能够成功创建react-native bundle --entry-file ./index.js --platform ios --bundle-output ios/main.jsbundle --verbose,但是不幸的是,这并不是应用崩溃的根本原因,因为它仍然崩溃,并且现在静默地这样做。