NervJS / taro

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

3.5.5 空项目dev:rn后dev:h5报undefined (reading 'isBatchingLegacy') #12505

Closed limingwei closed 2 years ago

limingwei commented 2 years ago

相关平台

React Native

使用框架: React

复现步骤

mac node 18.7 taro init 项目 less ts 空模板 dev:h5 正常 dev:rn 正常 dev:h5 报undefined (reading 'isBatchingLegacy') 还原 package.json 和 lock install --force dev:h5 正常

期望结果

dev:h5 正常 dev:rn 正常 dev:weapp 正常

实际结果

dev:h5 正常 dev:rn 异常 dev:weapp 正常

环境信息

👽 Taro v3.5.5

  Taro CLI 3.5.5 environment info:
    System:
      OS: macOS 12.6
      Shell: 5.8.1 - /bin/zsh
    Binaries:
      Node: 18.7.0 - ~/.nvm/versions/node/v18.7.0/bin/node
      Yarn: 1.22.19 - ~/.nvm/versions/node/v18.7.0/bin/yarn
      npm: 8.15.0 - ~/.nvm/versions/node/v18.7.0/bin/npm
    npmPackages:
      @tarojs/cli: 3.5.5 => 3.5.5 
      @tarojs/components: 3.5.5 => 3.5.5 
      @tarojs/helper: 3.5.5 => 3.5.5 
      @tarojs/plugin-framework-react: 3.5.5 => 3.5.5 
      @tarojs/plugin-platform-alipay: 3.5.5 => 3.5.5 
      @tarojs/plugin-platform-jd: 3.5.5 => 3.5.5 
      @tarojs/plugin-platform-qq: 3.5.5 => 3.5.5 
      @tarojs/plugin-platform-swan: 3.5.5 => 3.5.5 
      @tarojs/plugin-platform-tt: 3.5.5 => 3.5.5 
      @tarojs/plugin-platform-weapp: 3.5.5 => 3.5.5 
      @tarojs/react: 3.5.5 => 3.5.5 
      @tarojs/rn-runner: ^3.5.5 => 3.5.5 
      @tarojs/router: 3.5.5 => 3.5.5 
      @tarojs/runtime: 3.5.5 => 3.5.5 
      @tarojs/shared: 3.5.5 => 3.5.5 
      @tarojs/taro: 3.5.5 => 3.5.5 
      @tarojs/taro-h5: 3.5.5 => 3.5.5 
      @tarojs/taro-rn: ^3.5.5 => 3.5.5 
      @tarojs/webpack5-runner: 3.5.5 => 3.5.5 
      babel-preset-taro: 3.5.5 => 3.5.5 
      eslint-config-taro: 3.5.5 => 3.5.5 
      expo: ~45.0.4 => 45.0.8 
      react: ^17.0.2 => 17.0.2 
limingwei commented 2 years ago

TypeError Cannot read properties of undefined (reading 'isBatchingLegacy') Call Stack  ensureRootIsScheduled   vendors-node_modules_taro_h5_prebundle_react-dom_js.js:18595:56  scheduleUpdateOnFiber   vendors-node_modules_taro_h5_prebundle_react-dom_js.js:18551:25  updateContainer   vendors-node_modules_taro_h5_prebundle_react-dom_js.js:20778:25  undefined   vendors-node_modules_taro_h5_prebundle_react-dom_js.js:21303:29  flushSync   vendors-node_modules_taro_h5_prebundle_react-dom_js.js:18935:36  legacyCreateRootFromDOMContainer   vendors-node_modules_taro_h5_prebundle_react-dom_js.js:21302:25  legacyRenderSubtreeIntoContainer   vendors-node_modules_taro_h5_prebundle_react-dom_js.js:21323:33  Object.render   vendors-node_modules_taro_h5_prebundle_react-dom_js.js:21386:28  renderReactRoot   vendors-node_modules_taro_h5_prebundle_chunk-KQAFAKAJ_js.js:284:78  Object.value [as onLaunch]   vendors-node_modules_taro_h5_prebundle_chunk-KQAFAKAJ_js.js:351:21

zhiqingchen commented 2 years ago

包管理用的 yarn 还是?

limingwei commented 2 years ago

npm

dumuzhou commented 2 years ago

+1 用的yarn

zhiqingchen commented 2 years ago

使用的是默认模板?

dumuzhou commented 2 years ago

用的mobx

zhiqingchen commented 2 years ago

reacrt 18 目前在 taro 的 rn 下还未支持。(需要 0.69 RN版本

dev:rn 会安装安装 react@17

可先把更新下 react-dom 版本

"react-dom": "^17.0.2",

limingwei commented 2 years ago

如下调整了

    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-native": "^0.68.3"

dev:h5 build:h5 dev:weapp build:weapp dev:rn 正常 无报错

build:rn 提示

**/Users/lmw/git/ewei-frontend/ewei-frontend-taro/node_modules/metro-hermes-compiler/src/emhermesc.js:77
          throw ex;
          ^

RuntimeError: abort(Error: Unable to resolve module @tarojs/components-rn/dist/components/View from /Users/lmw/git/ewei-frontend/ewei-frontend-taro/src/pages/index/index.tsx: @tarojs/components-rn/dist/components/View could not be found within the project or in these directories:
  node_modules
> 1 | import { Component, PropsWithChildren } from 'react'
  2 | import { View, Text } from '@tarojs/components'
  3 | import './index.less'
  4 |). Build with -s ASSERTIONS=1 for more info.
    at process.abort (/Users/lmw/git/ewei-frontend/ewei-frontend-taro/node_modules/metro-hermes-compiler/src/emhermesc.js:402:15)
    at process.emit (node:events:525:35)
    at emit (node:internal/process/promises:149:20)
    at processPromiseRejections (node:internal/process/promises:283:27)
    at processTicksAndRejections (node:internal/process/task_queues:96:32)**
zhiqingchen commented 2 years ago

未复现该问题。

尝试

watchman watch-del-all
yarn build:rn --platform ios --reset-cache

或提供 demo 仓库

limingwei commented 2 years ago

https://github.com/limingwei/taro-issue-12505-sample

zhiqingchen commented 2 years ago

npm i @tarojs/components-rn@3.5.5

推荐使用 yarn

limingwei commented 2 years ago

现在执行 dev 和 build 都不报错了

但 dev:weapp 后 在小程序开发工具中打开后报错

[system] LazyCodeLoading: false
VM27 WAServiceMainContext.js:1 Uncaught (in promise) undefined(env: macOS,mp,1.06.2208311; lib: 2.26.1)
(anonymous) @ VM27 WAServiceMainContext.js:1
_privEmit @ VM27 WAServiceMainContext.js:1
emit @ VM27 WAServiceMainContext.js:1
Be @ VM27 WAServiceMainContext.js:1
Ve @ VM27 WAServiceMainContext.js:1
(anonymous) @ VM27 WAServiceMainContext.js:1
emit @ VM27 WAServiceMainContext.js:1
c @ VM9 asdebug.js:10
(anonymous) @ instanceframe?s=1663645724380&autoload:19
Promise.then (async)
(anonymous) @ instanceframe?s=1663645724380&autoload:15
VM78:9 app.js错误:
 Error: Cannot find module 'react'
    at webpackEmptyContext (:25452/appservice/prebundle/node_modules_taro_weapp_prebundle_sync_recursive-_94893.js?t=wechat&s=1663645720989&v=70acca9a8ea6b2f8a47754fc9178903c:10)
    at $$$reconciler (:25452/appservice/prebundle/vendors-node_modules_taro_weapp_prebundle_react-dom_js.js?t=wechat&s=1663645720989&v=e7ed1cc1114381009de788abffe91d8a:291)
    at Object../node_modules/.taro/weapp/prebundle/react-dom.js (:25452/appservice/prebundle/vendors-node_modules_taro_weapp_prebundle_react-dom_js.js?t=wechat&s=1663645720989&v=e7ed1cc1114381009de788abffe91d8a:5814)
    at __webpack_require__ (:25452/appservice/runtime.js:24)
    at :25452/appservice/prebundle/remoteEntry.js?t=wechat&s=1663645720989&v=2c22ab35c2fa9d1eb6b64346bc1e6a4f:81
    at Object.webpack/container/remote/react-dom (:25452/appservice/runtime.js:257)
    at __webpack_require__ (:25452/appservice/runtime.js:24)
    at Object../src/app.ts (:25452/appservice/app.js:96)
    at __webpack_require__ (:25452/appservice/runtime.js:24)
    at __webpack_exec__ (:25452/appservice/app.js:123)(env: macOS,mp,1.06.2208311; lib: 2.26.1)
(anonymous) @ VM78:9
doWhenAllScriptLoaded @ VM55:6713
scriptLoaded @ VM55:6741
(anonymous) @ VM55:6766
Promise.then (async)
(anonymous) @ VM55:6787
(anonymous) @ VM55:6791
loadScripts @ VM17 assubloader.js:1
async function (async)
loadScripts @ VM17 assubloader.js:1
loadAppResourceScripts @ VM17 assubloader.js:1
(anonymous) @ VM47 app-service.js:1
VM27 WAServiceMainContext.js:1 Error: Cannot find module 'react'
    at webpackEmptyContext (:25452/appservice/prebundle/node_modules_taro_weapp_prebundle_sync_recursive-_94893.js?t=wechat&s=1663645720989&v=70acca9a8ea6b2f8a47754fc9178903c:10)
    at $$$reconciler (:25452/appservice/prebundle/vendors-node_modules_taro_weapp_prebundle_react-dom_js.js?t=wechat&s=1663645720989&v=e7ed1cc1114381009de788abffe91d8a:291)
    at Object../node_modules/.taro/weapp/prebundle/react-dom.js (:25452/appservice/prebundle/vendors-node_modules_taro_weapp_prebundle_react-dom_js.js?t=wechat&s=1663645720989&v=e7ed1cc1114381009de788abffe91d8a:5814)
    at __webpack_require__ (:25452/appservice/runtime.js:24)
    at :25452/appservice/prebundle/remoteEntry.js?t=wechat&s=1663645720989&v=2c22ab35c2fa9d1eb6b64346bc1e6a4f:81
    at Object.webpack/container/remote/react-dom (:25452/appservice/runtime.js:257)
    at __webpack_require__ (:25452/appservice/runtime.js:24)
    at Object../src/app.ts (:25452/appservice/app.js:96)
    at __webpack_require__ (:25452/appservice/runtime.js:24)
    at __webpack_exec__ (:25452/appservice/app.js:123)(env: macOS,mp,1.06.2208311; lib: 2.26.1)
errorReport @ VM27 WAServiceMainContext.js:1
thirdErrorReport @ VM27 WAServiceMainContext.js:1
(anonymous) @ VM27 WAServiceMainContext.js:1
a @ VM38 WASubContext.js:1
(anonymous) @ VM38 WASubContext.js:1
_privEmit @ VM38 WASubContext.js:1
emit @ VM38 WASubContext.js:1
(anonymous) @ VM38 WASubContext.js:1
Pe @ VM38 WASubContext.js:1
(anonymous) @ VM38 WASubContext.js:1
Pe @ VM38 WASubContext.js:1
onLoad @ VM38 WASubContext.js:1
re @ VM38 WASubContext.js:1
(anonymous) @ VM38 WASubContext.js:1
doWhenAllScriptLoaded @ VM55:6713
scriptLoaded @ VM55:6741
(anonymous) @ VM55:6766
error (async)
(anonymous) @ VM38 WASubContext.js:1
(anonymous) @ VM38 WASubContext.js:1
(anonymous) @ VM38 WASubContext.js:1
(anonymous) @ VM38 WASubContext.js:1
WAServiceMainContext.js?t=wechat&s=1663645720989&v=2.26.1:1 [system] WeChatLib: 2.26.1 (2022.9.19 18:51:41)
WAServiceMainContext.js?t=wechat&s=1663645720989&v=2.26.1:1 [system] Subpackages: N/A
WAServiceMainContext.js?t=wechat&s=1663645720989&v=2.26.1:1 [system] LazyCodeLoading: false
[基础库] 正在使用灰度中的基础库 2.26.1 进行调试。如有问题,请前往工具栏-详情-本地设置更改基础库版本。
VM143:9 app.js错误:
 Error: Cannot find module 'react'
    at webpackEmptyContext (node_modules_taro_weapp_prebundle_sync_recursive-_94893.js?t=wechat&s=1663645720989&v=70acca9a8ea6b2f8a47754fc9178903c:10)
    at $$$reconciler (vendors-node_modules_taro_weapp_prebundle_react-dom_js.js?t=wechat&s=1663645720989&v=e7ed1cc1114381009de788abffe91d8a:291)
    at Object../node_modules/.taro/weapp/prebundle/react-dom.js (vendors-node_modules_taro_weapp_prebundle_react-dom_js.js?t=wechat&s=1663645720989&v=e7ed1cc1114381009de788abffe91d8a:5814)
    at __webpack_require__ (webpack_bootstrap:19)
    at remoteEntry.js?t=wechat&s=1663645720989&v=2c22ab35c2fa9d1eb6b64346bc1e6a4f:81
    at Object.webpack/container/remote/react-dom (webpack_runtime_remotes loading:59)
    at __webpack_require__ (webpack_bootstrap:19)
    at Object../src/app.ts (._src_app.ts:18)
    at __webpack_require__ (webpack_bootstrap:19)
    at __webpack_exec__ (app.ts?7071:19)(env: macOS,mp,1.06.2208311; lib: 2.26.1)
(anonymous) @ VM143:9
doWhenAllScriptLoaded @ VM120:6713
scriptLoaded @ VM120:6741
(anonymous) @ VM120:6766
Promise.then (async)
(anonymous) @ VM120:6787
(anonymous) @ VM120:6791
loadScripts @ assubloader.js:1
async function (async)
loadScripts @ assubloader.js:1
loadAppResourceScripts @ assubloader.js:1
(anonymous) @ app-service.js:1
WAServiceMainContext.js?t=wechat&s=1663645720989&v=2.26.1:1 Error: Cannot find module 'react'
    at webpackEmptyContext (node_modules_taro_weapp_prebundle_sync_recursive-_94893.js?t=wechat&s=1663645720989&v=70acca9a8ea6b2f8a47754fc9178903c:10)
    at $$$reconciler (vendors-node_modules_taro_weapp_prebundle_react-dom_js.js?t=wechat&s=1663645720989&v=e7ed1cc1114381009de788abffe91d8a:291)
    at Object../node_modules/.taro/weapp/prebundle/react-dom.js (vendors-node_modules_taro_weapp_prebundle_react-dom_js.js?t=wechat&s=1663645720989&v=e7ed1cc1114381009de788abffe91d8a:5814)
    at __webpack_require__ (webpack_bootstrap:19)
    at remoteEntry.js?t=wechat&s=1663645720989&v=2c22ab35c2fa9d1eb6b64346bc1e6a4f:81
    at Object.webpack/container/remote/react-dom (webpack_runtime_remotes loading:59)
    at __webpack_require__ (webpack_bootstrap:19)
    at Object../src/app.ts (._src_app.ts:18)
    at __webpack_require__ (webpack_bootstrap:19)
    at __webpack_exec__ (app.ts?7071:19)(env: macOS,mp,1.06.2208311; lib: 2.26.1)
errorReport @ WAServiceMainContext.js?t=wechat&s=1663645720989&v=2.26.1:1
thirdErrorReport @ WAServiceMainContext.js?t=wechat&s=1663645720989&v=2.26.1:1
(anonymous) @ WAServiceMainContext.js?t=wechat&s=1663645720989&v=2.26.1:1
a @ WASubContext.js?t=wechat&s=1663645720989&v=2.26.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1663645720989&v=2.26.1:1
_privEmit @ WASubContext.js?t=wechat&s=1663645720989&v=2.26.1:1
emit @ WASubContext.js?t=wechat&s=1663645720989&v=2.26.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1663645720989&v=2.26.1:1
Pe @ WASubContext.js?t=wechat&s=1663645720989&v=2.26.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1663645720989&v=2.26.1:1
Pe @ WASubContext.js?t=wechat&s=1663645720989&v=2.26.1:1
onLoad @ WASubContext.js?t=wechat&s=1663645720989&v=2.26.1:1
re @ WASubContext.js?t=wechat&s=1663645720989&v=2.26.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1663645720989&v=2.26.1:1
doWhenAllScriptLoaded @ VM120:6713
scriptLoaded @ VM120:6741
(anonymous) @ VM120:6766
error (async)
(anonymous) @ WASubContext.js?t=wechat&s=1663645720989&v=2.26.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1663645720989&v=2.26.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1663645720989&v=2.26.1:1
(anonymous) @ WASubContext.js?t=wechat&s=1663645720989&v=2.26.1:1
WASubContext.js?t=wechat&s=1663645720989&v=2.26.1:1 Page "pages/index/index" has not been registered yet.
WAServiceMainContext.js?t=wechat&s=1663645720989&v=2.26.1:1 [system] Launch Time: 1557 ms
:25452/appservice/instanceframe?s=1663645724380&autoload#id_2:1 Uncaught (in promise) undefined(env: macOS,mp,1.06.2208311; lib: 2.26.1)
worker.js?libName=WAAccelerateWorker.js:1 [Deprecation] SharedArrayBuffer will require cross-origin isolation as of M92, around July 2021. See https://developer.chrome.com/blog/enabling-shared-array-buffer/ for more details.
e.onmessage @ worker.js?libName=WAAccelerateWorker.js:1
worker.js?libName=WAAccelerateWorker.js:1 [worker] reportRealtimeAction:fail not support
e.workerInvokeJsApi @ worker.js?libName=WAAccelerateWorker.js:1
(anonymous) @ WAWorker.js:1
invoke @ WAWorker.js:1
invoke @ WAWorker.js:1
D @ WAWorker.js:1
(anonymous) @ WAWorker.js:1
Ae @ WAWorker.js:1
U @ WAWorker.js:1
p @ WAWorker.js:1
(anonymous) @ WAWorker.js:1
(anonymous) @ WAWorker.js:1
setTimeout (async)
globalThis.setTimeout @ WAWorker.js:1
(anonymous) @ WAWorker.js:1
ye @ WAWorker.js:1
(anonymous) @ WAWorker.js:1
s @ WAWorker.js:1
callAndRemove @ WAWorker.js:1
invokeCallbackHandler @ WAWorker.js:1
eval @ VM10:1
e.onmessage @ worker.js?libName=WAAccelerateWorker.js:1
limingwei commented 2 years ago

且 用 Taro Playground 1.0 RN 0.70 Taro 3.5.5 扫描打开后 Screenshot_2022-09-20-11-53-26-117_com playground taro

zhiqingchen commented 2 years ago

https://github.com/wuba/taro-playground/releases/tag/v1.6.4

0.70 及 0.69 还未正式发布,请使用 0.68

limingwei commented 2 years ago

感谢 RN 已经正常 现在剩余 dev:weapp 报错的问题

zhiqingchen commented 2 years ago
rm -rf node_modules
yarn
yarn dev:weapp
limingwei commented 2 years ago

好了,感谢 目前看问题都已解决

limingwei commented 2 years ago

问题是解决了,但我感觉,事儿还没完吧 参考官网的资料,敲命令,各种默认选项;东西跑不起来,这事儿应该还是得处理吧

zhiqingchen commented 2 years ago

欢迎建议或pr

ShawnZeng commented 1 year ago

我按照 rm -rf node_modules yarn yarn dev:weapp 处理的,微信小程序里面还是报错。Cannot read property 'isBatchingLegacy' of undefined

    "react": "^17.0.0",
    "react-dom": "^17.0.0",
    "react-redux": "^7.2.6",
    "redux": "^4.1.2",
Zhou-Bill commented 1 year ago

用的mobx

请问解决了吗

IOLOII commented 12 months ago

参考官网的资料,敲命令,各种默认选项;东西跑不起来,这事儿应该还是得处理吧

在使用的过程中也正在遇到问题,也是这种:模板运行之后出现一些问题