Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用v4.0.4脚手架安装 react vite 版本 编译微信小程序报错 #16226

Open
DankeBIBI opened this issue Aug 2, 2024 · 18 comments
Open
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x

Comments

@DankeBIBI
Copy link

相关平台

微信小程序

小程序基础库: 3.5.1
使用框架: React

复现步骤

正常使用taro 命令创建项目,然后 dev:weapp

首先缺少
✓ 1 modules transformed.
[babel] [BABEL] D:\project\react-test\D:\project\react-test\src\app.ts?entry-loader=true: Cannot find module '@babel/preset-react'

然后缺少
✓ 1 modules transformed.
[babel] [BABEL] D:\project\react-test\D:\project\react-test\src\app.ts?entry-loader=true: Cannot find module '@babel/plugin-proposal-class-properties'

然后安装依赖完毕后 run dev:weapp

微信开发工具控制台报

app.js错误:
TypeError: taro.getDefaultExportFromCjs is not a function

期望结果

正常运行

实际结果

报错

环境信息

👽 Taro v4.0.4


  Taro CLI 4.0.4 environment info:
    System:
      OS: Windows 11 10.0.22631
    Binaries:
      Node: 18.20.0 - C:\Program Files\nodejs\node.EXE
      Yarn: 1.22.22 - C:\Program Files\nodejs\yarn.CMD
      npm: 10.5.0 - C:\Program Files\nodejs\npm.CMD
    npmPackages:
      @tarojs/cli: 4.0.4 => 4.0.4
      @tarojs/components: 4.0.4 => 4.0.4
      @tarojs/helper: 4.0.4 => 4.0.4
      @tarojs/plugin-framework-react: 4.0.4 => 4.0.4
      @tarojs/plugin-html: 4.0.4 => 4.0.4
      @tarojs/plugin-platform-alipay: 4.0.4 => 4.0.4
      @tarojs/plugin-platform-h5: 4.0.4 => 4.0.4
      @tarojs/plugin-platform-jd: 4.0.4 => 4.0.4
      @tarojs/plugin-platform-qq: 4.0.4 => 4.0.4
      @tarojs/plugin-platform-swan: 4.0.4 => 4.0.4
      @tarojs/plugin-platform-tt: 4.0.4 => 4.0.4
      @tarojs/plugin-platform-weapp: 4.0.4 => 4.0.4
      @tarojs/react: 4.0.4 => 4.0.4
      @tarojs/runtime: 4.0.4 => 4.0.4
      @tarojs/shared: 4.0.4 => 4.0.4
      @tarojs/taro: 4.0.4 => 4.0.4
      @tarojs/vite-runner: 4.0.4 => 4.0.4
      babel-preset-taro: 4.0.4 => 4.0.4
      eslint-config-taro: 4.0.4 => 4.0.4
      react: ^18.0.0 => 18.3.1
@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Aug 2, 2024
@zyh9
Copy link

zyh9 commented Aug 2, 2024

  1. @babel/preset-react
  2. @babel/plugin-proposal-class-properties
  3. @tarojs/binding-darwin-arm64 「主要针对 ARM 架构芯片」

装一下依赖就好啦

This was referenced Aug 3, 2024
@TheKonka
Copy link
Member

TheKonka commented Aug 4, 2024

想入坑, 怎奈报错太多, 我taro+vite+sass +nutui+react, 他连wxss 文件都没给我生成 安装 依赖还要加--force, 运行起来页面空白,各种报错

可以先用v3, v4 刚出,坑是不少

@DankeBIBI
Copy link
Author

  1. @babel/preset-react
  2. @babel/plugin-proposal-class-properties
  3. @tarojs/binding-darwin-arm64 「主要针对 ARM 架构芯片」

装一下依赖就好啦

好的,我尝试下

@DankeBIBI
Copy link
Author

想入坑, 怎奈报错太多, 我taro+vite+sass +nutui+react, 他连wxss 文件都没给我生成 安装 依赖还要加--force, 运行起来页面空白,各种报错

我本来想把uni-vue3 重构成taro-react的,结果我按着文档来拉模板都会少依赖

@skylingfly
Copy link

mark, 依然启动起来报错 TypeError: taro.getDefaultExportFromCjs is not a function

@Phyzait
Copy link

Phyzait commented Aug 7, 2024

mark, 依然启动起来报错 TypeError: taro.getDefaultExportFromCjs is not a function

package.json->browserslist 改成这样

{
  "browserslist": [
      "defaults and fully supports es6-module",
      "maintained node versions"
    ],
}

但是Form的children显示不出来,目前没试其他组件

@pdb3616109
Copy link

原来不止我一个人这样😭

@maoxia1990
Copy link

直接用其模板,同样问题加,最新版本:v4.0.5。
image

image

@logeast
Copy link

logeast commented Sep 24, 2024

求解决方案,mac m1 报错

@dyt123456
Copy link

直接用其模板,同样问题加,最新版本:v4.0.5。 图像

图像

我也出现了一模一样的问题 请问你解决了吗?我用yarn命令去引用其react-NutUI模板就不得行

@TuringZhu
Copy link

@dyt123456 一个是上面 DankeBIBI 说的安装依赖, 一个是上面 Phyzait 说的修改浏览器列表

@XiangyiZhang
Copy link

直接用其模板,同样问题加,最新版本:v4.0.5。 image

image


同报错,m1芯片

@xixihhhh
Copy link

两种方法都试了,还是报错

@xixihhhh
Copy link

4.0.7还是报错

@yanlongqi
Copy link

4.0.7了,这个问题你们解决了没有,我也遇到了

@xixihhhh
Copy link

4.0.7了,这个问题你们解决了没有,我也遇到了

我退回到4.0.0-beta.82就不报错了,只能先用着,看看后面有没有啥解决方法

@DankeBIBI
Copy link
Author

4.0.7了,这个问题你们解决了没有,我也遇到了

没去关注了,之前公司搞个小程序想用这个框架的,后来报错就换了别的

@DankeBIBI DankeBIBI closed this as not planned Won't fix, can't repro, duplicate, stale Oct 29, 2024
@DankeBIBI DankeBIBI reopened this Oct 29, 2024
@TuringZhu
Copy link

4.0.7了,这个问题你们解决了没有,我也遇到了

没去关注了,之前公司搞个小程序想用这个框架的,后来报错就换了别的

你们换了uniapp还是什么

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Projects
Status: In Progress
Development

No branches or pull requests