const open = require('open'); ^ Error [ERR_REQUIRE_ESM]: require() of ES Module at Object.<anonymous> (C:\Users\83422\AppData\Local\npm-cache\_npx\c3b18f2de609c2ae\node_modules\nrm\cli.js:9:14) { code: 'ERR_REQUIRE_ESM' } Node.js v18.16.0
原因
1
应该使用 open 的 CommonJs规范的包 ,现在 open v9.0.0 是 ES Module 版本的包
解决办法
1
npm install -g nrm open@8.4.2 --save
2.2 error Command failed with exit code 1: yarn install
现象
1 2
error Command failed with exit code 1: yarn install warning react-native > @react-native/codegen > jscodeshift > @babel/plugin-proposal-nullish-coalescing-operator@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
2.3 React Native v0.72.4 is now available (your project is running on v0.71.8)
现象
1 2 3 4
info React Native v0.72.4 is now available (your project is running on v0.71.8). info Changelog: https://github.com/facebook/react-native/releases/tag/v0.72.4 info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.71.8 info For more info, check out "https://reactnative.dev/docs/upgrading".
解决办法
1 2 3
查看react版本信息 yarn info react 查看react-native版本信息 yarn info react-native 将package.json中的react-native从v0.71.8修改为"0.72.4"
2.4 Included build '....\node_modules\react-native-gradle-plugin' does not exist
现象
1 2 3 4 5 6 7 8 9
FAILURE: Build failed with an exception.
* What went wrong: Included build 'D:\Code\ReactNativeDode\RN_WanAndroid-master\node_modules\react-native-gradle-plugin' does not exist.
* Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights.
> Configure project :react-native-reanimated Android gradle plugin: 7.4.2 Gradle: 8.0.1 WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.
解决办法
在文件 gradle.properties 中启用 AGP 8.0 默认行为的预览时
1
android.disableAutomaticComponentCreation=true
2.7 Failed to transform react-android-0.72.3-debug.aar
错误现象
1 2 3 4 5
Failed to transform react-android-0.72.3-debug.aar (com.facebook.react:react-android:0.72.3) to match attributes {artifactType=android-aar-metadata, com.android.build.api.attributes.BuildTypeAttr=debug, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}.
Could not download react-android-0.72.3-debug.aar (com.facebook.react:react-android:0.72.3) > Could not get resource 'https://repo.maven.apache.org/maven2/com/facebook/react/react-android/0.72.3/react-android-0.72.3-debug.aar'. > Read timed out