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

Taro 4.0.5新建项目在支付宝小程序开发工具构建失败 #16560

Closed
xgaxpp opened this issue Sep 19, 2024 · 4 comments
Closed

Taro 4.0.5新建项目在支付宝小程序开发工具构建失败 #16560

xgaxpp opened this issue Sep 19, 2024 · 4 comments
Assignees
Labels
F-react Framework - React T-alipay Target - 编译到支付宝小程序 V-4 Version - 4.x

Comments

@xgaxpp
Copy link

xgaxpp commented Sep 19, 2024

相关平台

支付宝小程序

小程序基础库: 2.9.x
使用框架: React

复现步骤

1、新建项目
2、npm run dev:alipay
3、使用支付宝小程序开发工具打开dist目录

期望结果

正常预览

实际结果

编译失败:
For the selected environment is no default script chunk format available:
JSONP Array push can be chosen when 'document' or 'importScripts' is available.
CommonJs exports can be chosen when 'require' or node builtins are available.
Make sure that your 'browserslist' includes only platforms that support these features or select an appropriate 'target' to allow selecting a chunk format by default. Alternatively specify the 'output.chunkFormat' directly.

Dev server exited unexpectedly with code 1

Please try to restart by clicking 'Restart'

环境信息

  Taro CLI 4.0.5 environment info:
    System:
      OS: Windows 11 10.0.22631
    Binaries:
      Node: 20.17.0 - ~\AppData\Local\fnm_multishells\13428_1726727363059\node.EXE
      npm: 10.8.2 - ~\AppData\Local\fnm_multishells\13428_1726727363059\npm.CMD
    npmPackages:
      @tarojs/cli: 4.0.5 => 4.0.5
      @tarojs/components: 4.0.5 => 4.0.5
      @tarojs/helper: 4.0.5 => 4.0.5
      @tarojs/plugin-framework-react: 4.0.5 => 4.0.5
      @tarojs/plugin-platform-alipay: 4.0.5 => 4.0.5
      @tarojs/plugin-platform-h5: 4.0.5 => 4.0.5
      @tarojs/plugin-platform-harmony-hybrid: 4.0.5 => 4.0.5
      @tarojs/plugin-platform-jd: 4.0.5 => 4.0.5
      @tarojs/plugin-platform-qq: 4.0.5 => 4.0.5
      @tarojs/plugin-platform-swan: 4.0.5 => 4.0.5
      @tarojs/plugin-platform-tt: 4.0.5 => 4.0.5
      @tarojs/plugin-platform-weapp: 4.0.5 => 4.0.5
      @tarojs/react: 4.0.5 => 4.0.5
      @tarojs/runtime: 4.0.5 => 4.0.5
      @tarojs/shared: 4.0.5 => 4.0.5
      @tarojs/taro: 4.0.5 => 4.0.5
      @tarojs/vite-runner: 4.0.5 => 4.0.5
      babel-preset-taro: 4.0.5 => 4.0.5
      eslint-config-taro: 4.0.5 => 4.0.5
      react: ^18.0.0 => 18.3.1
@TheKonka TheKonka added F-react Framework - React T-alipay Target - 编译到支付宝小程序 V-4 Version - 4.x labels Sep 19, 2024
@TheKonka
Copy link
Member

支付宝小程序需要一个专门的配置文件 mini.project.json ,直接打开 dist 目录会导致修改的项目配置得不到保存,所以不建议这样做,推荐直接打开项目根目录,然后配置文件内容可以参考

#16271 (comment)

This was referenced Sep 21, 2024
@yeeli
Copy link

yeeli commented Oct 4, 2024

支付宝小程序需要一个专门的配置文件 mini.project.json ,直接打开 dist 目录会导致修改的项目配置得不到保存,所以不建议这样做,推荐直接打开项目根目录,然后配置文件内容可以参考

#16271 (comment)

和transpile没什么关系, 3.6.35运行就没什么问题, 在4.0就是无法构建, 我还特地新建了一个空白项目, 直接出现上面的构建错误

@taro-bot2 taro-bot2 bot removed the to be closed label Oct 6, 2024
@taro-bot2 taro-bot2 bot closed this as completed Oct 6, 2024
@koppthe koppthe self-assigned this Oct 12, 2024
@koppthe
Copy link
Contributor

koppthe commented Oct 12, 2024

找到问题了,4.0.7 版本会修复

@koppthe koppthe reopened this Oct 12, 2024
@koppthe
Copy link
Contributor

koppthe commented Oct 14, 2024

支付宝小程序需要一个专门的配置文件 mini.project.json ,直接打开 dist 目录会导致修改的项目配置得不到保存,所以不建议这样做,推荐直接打开项目根目录,然后配置文件内容可以参考
#16271 (comment)

和transpile没什么关系, 3.6.35运行就没什么问题, 在4.0就是无法构建, 我还特地新建了一个空白项目, 直接出现上面的构建错误

这是因为 taro v4.0 更改了 browserslist 的配置,默认只构建 es6,所以升级 4.0 之后,需要手动在 mini.project.json 中添加 transpile 配置

koppthe added a commit that referenced this issue Oct 16, 2024
* chore: 补全缺失的依赖 #16515

* feat(alipay): 新增 browserslist 配置 #16560
@taro-bot2 taro-bot2 bot removed the to be closed label Oct 22, 2024
@taro-bot2 taro-bot2 bot closed this as completed Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-alipay Target - 编译到支付宝小程序 V-4 Version - 4.x
Projects
None yet
Development

No branches or pull requests

6 participants
@koppthe @yeeli @xgaxpp @TheKonka and others