NervJS / taro

开放式跨端跨框架解决方案,支持使用 React/Vue/Nerv 等框架来开发微信/京东/百度/支付宝/字节跳动/ QQ 小程序/H5/React Native 等应用。 https://taro.zone/
https://docs.taro.zone/
Other
35.66k stars 4.8k forks source link

在执行npm run build:rn时报错 unknown field `cwd` at module.exports.__wbindgen_error_new #14137

Closed enjoylee-lionjoy closed 1 year ago

enjoylee-lionjoy commented 1 year ago

相关平台

React Native

使用框架: React

复现步骤

? 请输入项目名称! bajiaoren
? 请输入项目介绍
? 请选择框架 React
? 是否需要使用 TypeScript ? No
? 请选择 CSS 预处理器(Sass/Less/Stylus) 无
? 请选择编译工具 Webpack4
? 请选择包管理工具 yarn
? 请选择模板源 Gitee(最快)
✔ 拉取远程模板仓库成功!
? 请选择模板 react-native
...
✔ 创建文件: E:\baJoinApp\bajiaoren\android\app\src\main\java\com\tarodemo\newarchitecture\modules\MainApplicationTurboModuleManagerDelegate.java
✔ 项目名更新成功!
✔ cd bajiaoren, 执行 git init
yarn install v1.22.19
info No lockfile found.
[1/4] Resolving packages...
⚠ warning @tarojs/rn-supporter > metro > metro-minify-uglify > uglify-es@3.3.9: support for ECMAScript is superseded by `uglify-js` as of v3.13.0
⚠ warning @tarojs/rn-supporter > react-native-svg-transformer > @svgr/plugin-svgo > svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
⚠ warning @tarojs/rn-supporter > react-native-svg-transformer > @svgr/plugin-svgo > svgo > stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
⚠ warning @tarojs/rn-supporter > @tarojs/rn-style-transformer > stylus > css > source-map-resolve@0.6.0: See https://github.com/lydell/source-map-resolve#deprecated
⚠ warning @tarojs/runtime-rn > @tarojs/components-rn > @ant-design/react-native > babel-runtime > core-js@2.6.12: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
⚠ warning @tarojs/runtime-rn > @tarojs/components-rn > @ant-design/react-native > react-native-codegen > jscodeshift > micromatch > snapdragon > source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
⚠ warning @tarojs/runtime-rn > @tarojs/components-rn > @ant-design/react-native > react-native-codegen > jscodeshift > micromatch > snapdragon > source-map-resolve > resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
⚠ warning @tarojs/runtime-rn > @tarojs/components-rn > @ant-design/react-native > react-native-codegen > jscodeshift > micromatch > snapdragon > source-map-resolve > source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
⚠ warning @tarojs/runtime-rn > @tarojs/components-rn > @ant-design/react-native > react-native-codegen > jscodeshift > micromatch > snapdragon > source-map-resolve > urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
⚠ warning @tarojs/taro-rn > expo-file-system > uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
⚠ warning @tarojs/cli > request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
⚠ warning @tarojs/cli > request > uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
⚠ warning @tarojs/cli > request > har-validator@5.1.5: this library is no longer supported
⚠ warning @tarojs/rn-runner > @rollup/plugin-replace > magic-string > sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead
⚠ warning @tarojs/mini-runner > copy-webpack-plugin > webpack-log > uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
⚠ warning @tarojs/mini-runner > terser-webpack-plugin > cacache > @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
⚠ warning @tarojs/mini-runner > @tarojs/runner-utils > scss-bundle > @types/sass@1.45.0: This is a stub types definition. sass provides its own type definitions, so you do not need this installed.
⚠ warning @tarojs/mini-runner > webpack > watchpack > watchpack-chokidar2 > chokidar@2.1.8: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies
⚠ warning @tarojs/mini-runner > webpack > watchpack > watchpack-chokidar2 > chokidar > fsevents@1.2.13: The v1 package contains DANGEROUS / INSECURE binaries. Upgrade to safe fsevents v2
⚠ warning @tarojs/webpack-runner > webpack-dev-server > chokidar@2.1.8: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies
⚠ warning @tarojs/webpack-runner > resolve-url-loader > rework > css > source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
warning @tarojs/webpack-runner > resolve-url-loader > rework > css > urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
⚠ warning install-peerdeps > @babel/polyfill@7.12.1: 🚨 This package has been deprecated in favor of separate inclusion of a polyfill and regenerator-runtime (when needed). See the @babel/polyfill docs (https://babeljs.io/docs/en/babel-polyfill) for more information.
⚠ warning install-peerdeps > @babel/polyfill > core-js@2.6.12: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
⚠ warning stylelint > file-entry-cache > flat-cache > circular-json@0.3.3: CircularJSON is in maintenance only, flatted is its successor.
⚠ warning stylelint > postcss-markdown > remark > remark-parse > trim@0.0.1: Use String.prototype.trim() instead
[2/4] Fetching packages...
[3/4] Linking dependencies...
⚠ warning "@tarojs/rn-supporter > react-native-svg-transformer@0.14.3" has unmet peer dependency "react-native-svg@>=6.5.1".
⚠ warning "@tarojs/runtime-rn > @tarojs/router-rn@3.6.6" has unmet peer dependency "@react-native-masked-view/masked-view@~0.2.7".
warning "@tarojs/runtime-rn > @tarojs/router-rn@3.6.6" has unmet peer dependency "react-native-gesture-handler@~2.9.0".
⚠ warning "@tarojs/runtime-rn > @tarojs/router-rn@3.6.6" has unmet peer dependency "react-native-safe-area-context@~4.4.1".
warning "@tarojs/runtime-rn > @tarojs/router-rn@3.6.6" has unmet peer dependency "react-native-screens@^3.18.2".
warning "@tarojs/runtime-rn > @tarojs/components-rn@3.6.6" has unmet peer dependency "@react-native-community/slider@~4.3.2".
warning "@tarojs/runtime-rn > @tarojs/components-rn@3.6.6" has unmet peer dependency "@react-native-picker/picker@~2.4.2".
warning "@tarojs/runtime-rn > @tarojs/components-rn@3.6.6" has unmet peer dependency "expo@~47.0.3".
warning "@tarojs/runtime-rn > @tarojs/components-rn@3.6.6" has unmet peer dependency "expo-av@~13.0.0".
warning "@tarojs/runtime-rn > @tarojs/components-rn@3.6.6" has unmet peer dependency "expo-barcode-scanner@~12.0.0".
warning "@tarojs/runtime-rn > @tarojs/components-rn@3.6.6" has unmet peer dependency "expo-camera@~13.0.0".
warning "@tarojs/runtime-rn > @tarojs/components-rn@3.6.6" has unmet peer dependency "react-native-pager-view@~6.0.1".
warning "@tarojs/runtime-rn > @tarojs/components-rn@3.6.6" has unmet peer dependency "react-native-svg@~13.7.0".
warning "@tarojs/runtime-rn > @tarojs/components-rn@3.6.6" has unmet peer dependency "react-native-webview@~11.23.0".
warning "@tarojs/taro-rn > expo-barcode-scanner@12.0.0" has unmet peer dependency "expo@*".
warning "@tarojs/taro-rn > expo-av@13.0.3" has unmet peer dependency "expo@*".
⚠ warning "@tarojs/runtime-rn > @tarojs/components-rn > @ant-design/react-native@5.0.4" has unmet peer dependency "@react-native-camera-roll/camera-roll@>= 5.0.0".
warning "@tarojs/runtime-rn > @tarojs/components-rn > @ant-design/react-native@5.0.4" has unmet peer dependency "@react-native-community/segmented-control@>= 1.4.0".
warning "@tarojs/runtime-rn > @tarojs/components-rn > @ant-design/react-native@5.0.4" has unmet peer dependency "react-native-gesture-handler@^2.2.1".
warning "@tarojs/taro-rn > expo-camera@13.0.0" has unmet peer dependency "expo@*".
warning "@tarojs/taro-rn > expo-image-picker > expo-image-loader@4.0.0" has unmet peer dependency "expo@*".
⚠ warning "@tarojs/runtime-rn > @tarojs/components-rn > @ant-design/react-native > react-native-codegen > jscodeshift@0.11.0" has unmet peer dependency "@babel/preset-env@^7.1.6".
warning "@tarojs/runtime-rn > @tarojs/components-rn > expo-camera > @koale/useworker@4.0.2" has incorrect peer dependency "react@^16.8.0".
warning " > @tarojs/taro-rn@3.6.6" has unmet peer dependency "@bam.tech/react-native-image-resizer@~3.0.4".
warning " > @tarojs/taro-rn@3.6.6" has unmet peer dependency "@react-native-async-storage/async-storage@~1.17.7".
warning " > @tarojs/taro-rn@3.6.6" has unmet peer dependency "@react-native-camera-roll/camera-roll@~5.0.4".
⚠ warning " > @tarojs/taro-rn@3.6.6" has unmet peer dependency "@react-native-clipboard/clipboard@~1.11.1".
warning " > @tarojs/taro-rn@3.6.6" has unmet peer dependency "@react-native-community/geolocation@~3.0.2".
warning " > @tarojs/taro-rn@3.6.6" has unmet peer dependency "@react-native-community/netinfo@~9.3.0".
warning " > @tarojs/taro-rn@3.6.6" has unmet peer dependency "expo-av@~13.0.0".
warning " > @tarojs/taro-rn@3.6.6" has unmet peer dependency "expo-barcode-scanner@~12.0.0".
warning " > @tarojs/taro-rn@3.6.6" has unmet peer dependency "expo-brightness@~11.0.0".
warning " > @tarojs/taro-rn@3.6.6" has unmet peer dependency "expo-camera@~13.0.0".
warning " > @tarojs/taro-rn@3.6.6" has unmet peer dependency "expo-file-system@~15.1.1".
warning " > @tarojs/taro-rn@3.6.6" has unmet peer dependency "expo-image-picker@~14.0.0".
warning " > @tarojs/taro-rn@3.6.6" has unmet peer dependency "expo-keep-awake@~11.0.1".
warning " > @tarojs/taro-rn@3.6.6" has unmet peer dependency "expo-location@~15.0.1".
warning " > @tarojs/taro-rn@3.6.6" has unmet peer dependency "expo-sensors@~12.0.1".
warning " > @tarojs/taro-rn@3.6.6" has unmet peer dependency "react-native-device-info@~10.3.0".
warning " > @tarojs/taro-rn@3.6.6" has unmet peer dependency "react-native-safe-area-context@~4.4.1".
⚠ warning " > @tarojs/taro-rn@3.6.6" has unmet peer dependency "react-native-syan-image-picker@0.5.3".
warning "@tarojs/taro-rn > expo-file-system@15.1.1" has unmet peer dependency "expo@*".
warning "@tarojs/taro-rn > expo-brightness@11.0.1" has unmet peer dependency "expo@*".
warning "@tarojs/taro-rn > expo-keep-awake@11.0.1" has unmet peer dependency "expo@*".
⚠ warning "@tarojs/taro-rn > expo-image-picker@14.0.3" has unmet peer dependency "expo@*".
warning "@tarojs/taro-rn > expo-location@15.0.1" has unmet peer dependency "expo@*".
warning "@tarojs/taro-rn > expo-sensors@12.0.1" has unmet peer dependency "expo@*".
⚠ warning " > react-native@0.70.12" has incorrect peer dependency "react@18.1.0".
warning "react-native > react-native-codegen > jscodeshift@0.13.1" has unmet peer dependency "@babel/preset-env@^7.1.6".
⚠ warning "@tarojs/rn-runner > acorn-jsx@5.3.2" has unmet peer dependency "acorn@^6.0.0 || ^7.0.0 || ^8.0.0".
⚠ warning "@tarojs/rn-runner > @rollup/plugin-json@4.1.0" has unmet peer dependency "rollup@^1.20.0 || ^2.0.0".
warning "@tarojs/rn-runner > @rollup/plugin-replace@4.0.0" has unmet peer dependency "rollup@^1.20.0 || ^2.0.0".
warning "@tarojs/rn-runner > @rollup/plugin-node-resolve@13.3.0" has unmet peer dependency "rollup@^2.42.0".
warning "@tarojs/rn-runner > @rollup/plugin-commonjs@20.0.0" has unmet peer dependency "rollup@^2.38.3".
warning "@tarojs/rn-runner > @rollup/plugin-babel@5.3.1" has unmet peer dependency "rollup@^1.20.0||^2.0.0".
⚠ warning "@tarojs/rn-runner > @rollup/plugin-json > @rollup/pluginutils@3.1.0" has unmet peer dependency "rollup@^1.20.0||^2.0.0".
[4/4] Building fresh packages...
success Saved lockfile.
Done in 91.27s.
✔ 安装成功
创建项目 bajiaoren 成功!
请进入项目目录 bajiaoren 开始工作吧!😝

$ yarn upgradePeerdeps
yarn run v1.22.19
SUCCESS The peerDeps of @tarojs/taro-rn were installed successfully.
SUCCESS The peerDeps of @tarojs/components-rn were installed successfully.
SUCCESS The peerDeps of @tarojs/router-rn were installed successfully.
Scanning for pods...
CocoaPods is only supported on darwin machines
Done in 40.45s.

$ npm run build:rn

期望结果

执行成功

实际结果

bajiaoren@1.0.0 build:rn taro build --type rn

👽 Taro v3.6.6

Error: Bindings not found at Compiler.transformSync (E:\baJoinApp\bajiaoren\node_modules\@swc\core\index.js:250:15) at Object.transformSync (E:\baJoinApp\bajiaoren\node_modules\@swc\core\index.js:348:21) at compile (E:\baJoinApp\bajiaoren\node_modules\@swc\register\lib\node.js:76:22) at compileHook (E:\baJoinApp\bajiaoren\node_modules\@swc\register\lib\node.js:91:16) at Module._compile (E:\baJoinApp\bajiaoren\node_modules\pirates\lib\index.js:113:29) at Module._extensions..js (node:internal/modules/cjs/loader:1308:10) at Object.newLoader [as .js] (E:\baJoinApp\bajiaoren\node_modules\pirates\lib\index.js:121:7) at Module.load (node:internal/modules/cjs/loader:1117:32) at Module._load (node:internal/modules/cjs/loader:958:12) at Module.require (node:internal/modules/cjs/loader:1141:19) Error: Bindings not found at Compiler.transformSync (E:\baJoinApp\bajiaoren\node_modules\@swc\core\index.js:250:15) at Object.transformSync (E:\baJoinApp\bajiaoren\node_modules\@swc\core\index.js:348:21) at compile (E:\baJoinApp\bajiaoren\node_modules\@swc\register\lib\node.js:76:22) at compileHook (E:\baJoinApp\bajiaoren\node_modules\@swc\register\lib\node.js:91:16) at Module._compile (E:\baJoinApp\bajiaoren\node_modules\pirates\lib\index.js:113:29) at Module._extensions..js (node:internal/modules/cjs/loader:1308:10) at Object.newLoader [as .js] (E:\baJoinApp\bajiaoren\node_modules\pirates\lib\index.js:121:7) at Module.load (node:internal/modules/cjs/loader:1117:32) at Module._load (node:internal/modules/cjs/loader:958:12) at Module.require (node:internal/modules/cjs/loader:1141:19) E:\baJoinApp\bajiaoren\node_modules\@tarojs\service\dist\utils\index.js:89 throw new Error(插件依赖 "${item}" 加载失败,请检查插件配置); ^

Error: 插件依赖 "E:\baJoinApp\bajiaoren\node_modules\@tarojs\cli\dist\presets\index.js" 加载失败,请检查插件配置 at apply (E:\baJoinApp\bajiaoren\node_modules\@tarojs\service\dist\utils\index.js:89:31) at Kernel.initPreset (E:\baJoinApp\bajiaoren\node_modules\@tarojs\service\dist\Kernel.js:117:38) at Kernel.resolvePresets (E:\baJoinApp\bajiaoren\node_modules\@tarojs\service\dist\Kernel.js:92:18) at Kernel.initPresetsAndPlugins (E:\baJoinApp\bajiaoren\node_modules\@tarojs\service\dist\Kernel.js:86:14) at Kernel. (E:\baJoinApp\bajiaoren\node_modules\@tarojs\service\dist\Kernel.js:306:18) at Generator.next () at E:\baJoinApp\bajiaoren\node_modules\@tarojs\service\dist\Kernel.js:8:71 at new Promise () at __awaiter (E:\baJoinApp\bajiaoren\node_modules\@tarojs\service\dist\Kernel.js:4:12) at Kernel.run (E:\baJoinApp\bajiaoren\node_modules\@tarojs\service\dist\Kernel.js:290:16)

Node.js v18.16.0

环境信息

👽 Taro v3.6.6

  Taro CLI 3.6.6 environment info:
    System:
      OS: Windows 10 10.0.22000
    Binaries:
      Node: 18.16.0 - C:\Program Files\nodejs\node.EXE
      Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
      npm: 9.5.1 - C:\Program Files\nodejs\npm.CMD
    npmPackages:
      @tarojs/cli: 3.6.6 => 3.6.6
      @tarojs/components: 3.6.6 => 3.6.6
      @tarojs/helper: 3.6.6 => 3.6.6
      @tarojs/mini-runner: 3.6.6 => 3.6.6
      @tarojs/plugin-framework-react: 3.6.6 => 3.6.6
      @tarojs/plugin-platform-alipay: 3.6.6 => 3.6.6
      @tarojs/plugin-platform-h5: 3.6.6 => 3.6.6
      @tarojs/plugin-platform-jd: 3.6.6 => 3.6.6
      @tarojs/plugin-platform-qq: 3.6.6 => 3.6.6
      @tarojs/plugin-platform-swan: 3.6.6 => 3.6.6
      @tarojs/plugin-platform-tt: 3.6.6 => 3.6.6
      @tarojs/plugin-platform-weapp: 3.6.6 => 3.6.6
      @tarojs/react: 3.6.6 => 3.6.6
      @tarojs/rn-runner: 3.6.6 => 3.6.6
      @tarojs/rn-supporter: 3.6.6 => 3.6.6
      @tarojs/runtime: 3.6.6 => 3.6.6
      @tarojs/runtime-rn: 3.6.6 => 3.6.6
      @tarojs/shared: 3.6.6 => 3.6.6
      @tarojs/taro: 3.6.6 => 3.6.6
      @tarojs/taro-rn: 3.6.6 => 3.6.6
      @tarojs/webpack-runner: 3.6.6 => 3.6.6
      babel-preset-taro: 3.6.6 => 3.6.6
      eslint-config-taro: 3.6.6 => 3.6.6
      expo: ~47.0.3 => 47.0.14
      react: ^18.1.0 => 18.2.0
      react-native: ^0.70.1 => 0.70.12
enjoylee-lionjoy commented 1 year ago

按照百度到的某个教程 安装了c++依赖重启电脑后,依旧存在这个问题。删除node_modules文件夹后 重新安装依赖依旧存在。代码并未做任何更改,严格按照官方文档要求一步一步操作。

zhiqingchen commented 1 year ago

https://github.com/zhiqingchen/taro-test

参考,正常通过编译的分支

aresuper commented 1 year ago

按照百度到的某个教程 安装了c++依赖重启电脑后,依旧存在这个问题。删除node_modules文件夹后 重新安装依赖依旧存在。代码并未做任何更改,严格按照官方文档要求一步一步操作。

解决了吗?我也遇到类似的问题 不过我只是正常Taro小程序项目

shaohao123 commented 1 year ago

加一 求解决了么

Chen-jj commented 1 year ago

的确有收到不少同学反馈,swc 插件在 Windows 下需要安装 C++ 环境:https://github.com/NervJS/taro/issues/12676

各位可以安装 C++ 环境后,删除 node_modules 和 lockfile 后再试试的

jqroom commented 1 year ago

@enjoylee-lionjoy 我今天遇到了一样的问题,node 从14 升级到16、18后,去掉了所有的lockfile,也重新安装了npm包,问题还是存在,后面在这里找到了答案:https://github.com/swc-project/swc/issues/5616#issuecomment-1715561365@swc/core使用1.3.84版本

"@swc/core": "1.3.84"