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

68bkxrlz  于 2022-11-25  发布在  React
关注(0)|答案(1)|浏览(149)

我最近从React Native 0.53.3升级到了React Native 0.59.9,但我的应用程序在模拟器中不断崩溃。它会显示启动屏幕,然后崩溃,调试器UI中什么都没有,除了以下内容:
到“ws://localhost:8081/调试器代理?角色=调试器&名称=Chrome”的WebSocket连接失败:建立连接时出错:网络::错误连接被拒绝
我用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.

SO上与该错误相关的唯一帖子如下:

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

但这并不适用于我的情况。
问题似乎与node_modules内的@babel库有关,我曾尝试执行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)

但无论如何我还是会得到同样的错误。

q3qa4bjr

q3qa4bjr1#

实际上有两个独立的问题。
到“ws://localhost:8081/调试器代理?角色=调试器&名称=Chrome”的WebSocket连接失败:建立连接时出错:网络::错误连接被拒绝
一个错误与端口8081已经在使用的事实有关,所以我必须完全终止所有进程。
Babel和一个或两个自定义包之间确实存在一些依赖性问题,这两个包是主要的react-native-keyboard-managerreact-native-input-scroll-view。我删除了这些包,改用react-nativeScrollView
然后我能够成功运行:
react-native bundle --entry-file ./index.js --platform ios --bundle-output ios/main.jsbundle --verbose
这是能够成功地创建main.jsbundle,但不幸的是,这不是根本原因的应用程序崩溃,因为它仍然崩溃,并这样做沉默了。

相关问题