Pun*_*any 17 node.js react-native
我的 React Native 项目昨天运行良好。但是今天早上,在我尝试再次运行后,它给了我以下错误:
error node_modules/react-native/Libraries/Components/ScrollView/ScrollView.js: Property body[41] of BlockStatement expected node to be of a type ["Statement"] but instead got "AssignmentExpression". Run CLI with --verbose flag for more details.
TypeError: Property body[41] of BlockStatement expected node to be of a type ["Statement"] but instead got "AssignmentExpression"
Run Code Online (Sandbox Code Playgroud)
不过,我不确定这意味着什么。我该如何解决这个问题?
Arc*_*ano 19
这似乎是 Babel 7.15.0 的一个错误,他们正在为其进行E2E React 原生回归测试。
几个小时前,他们发布了修复程序。这是由于对@babel/plugin-transform-react-display-name的更改已在7.15.1. 使用该修复程序,您应该能够从我的原始答案中删除 package.json 中的额外条目,而是执行以下操作。
npm install --save-dev @babel/core@latest
不幸的是,仅仅降级@babel/core到 7.14 是不够的,因为它似乎为其他组件提取了最新的依赖项。相反,您需要做的是锁定@babel/core您正在使用的任何其他 Babel 组件,这些组件会强制@babel/types进入 7.15.0
这是我在 package.json 中的相关部分
"@babel/core": "~7.14.0",
"@babel/compat-data": "~7.14.0",
"@babel/generator": "~7.14.0",
"@babel/helper-compilation-targets": "~7.14.0",
"@babel/helper-create-class-features-plugin": "~7.14.0",
"@babel/helper-create-regexp-features-plugin": "~7.14.0",
"@babel/helper-member-expression-to-functions": "~7.14.0",
"@babel/helper-module-transforms": "~7.14.0",
"@babel/helper-replace-supers": "~7.14.0",
"@babel/plugin-transform-react-display-name": "~7.14.0",
"@babel/plugin-transform-runtime": "~7.14.0",
"@babel/types": "~7.14.0",
Run Code Online (Sandbox Code Playgroud)
只需替换所有这些并执行npm install并让它尝试再次解决和测试您的场景。如果仍然失败,只需查看 package-lock.json 并相应地定位7.15.0和调整依赖项
使用这种方法,您无需从 zip 文件中“恢复”。
Pun*_*any 14
显然,这可能是 babel 的问题。将工作项目的 node_modules 中的文件夹@babel(特别是@babel/core)复制到新项目中,它可以正常运行。
这可能是由于他们几个小时前所做的更新。
您还可以@babel/core从 package.json 中删除当前版本并安装此版本npm install --save-dev @babel/core@latest。
或者使用这个
@babel file:https://drive.google.com/file/d/1-z_4H_z4x075unZqZD41WYUwY_hsrKox/view。
或者替换package.json文件中的以下代码然后npm install.
"@babel/core": "~7.14.0",
"@babel/compat-data": "~7.14.0",
"@babel/generator": "~7.14.0",
"@babel/helper-compilation-targets": "~7.14.0",
"@babel/helper-create-class-features-plugin": "~7.14.0",
"@babel/helper-create-regexp-features-plugin": "~7.14.0",
"@babel/helper-member-expression-to-functions": "~7.14.0",
"@babel/helper-module-transforms": "~7.14.0",
"@babel/helper-replace-supers": "~7.14.0",
"@babel/plugin-transform-react-display-name": "~7.14.0",
"@babel/plugin-transform-runtime": "~7.14.0",
"@babel/types": "~7.14.0",
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2356 次 |
| 最近记录: |