NervJS / taro

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

Error: app.wxss from Css Minimizer plugin Error: [object Object] is not a PostCSS plugin #12609

Open gongzili456 opened 1 year ago

gongzili456 commented 1 year ago

相关平台

微信小程序

复现仓库

https://github.com/no 小程序基础库: 2.26.1 使用框架: React

复现步骤

taro init project

期望结果

期望编译通过

实际结果

⋊> ~/W/moto-focus-tarojs on main ⨯ npm run build:weapp 23:48:21

moto-focus-tarojs@1.0.0 build:weapp /Users/rory/WeChatProjects/moto-focus-tarojs taro build --type weapp

👽 Taro v3.5.6

Tips:

  1. 建议开启持久化缓存功能,能有效提升二次编译速度,详情请参考: https://docs.taro.zone/docs/config-detail#cache

✖ Webpack Compiled with some errors in 9.46s

✖ Errors:

Error: app.wxss from Css Minimizer plugin Error: [object Object] is not a PostCSS plugin

npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! moto-focus-tarojs@1.0.0 build:weapp: taro build --type weapp npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the moto-focus-tarojs@1.0.0 build:weapp script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /Users/rory/.npm/_logs/2022-10-03T15_48_35_617Z-debug.log

环境信息

👽 Taro v3.5.6

  Taro CLI 3.5.6 environment info:
    System:
      OS: macOS 12.6
      Shell: 3.5.1 - /usr/local/bin/fish
    Binaries:
      Node: 14.20.0 - ~/.nvm/versions/node/v14.20.0/bin/node
      Yarn: 1.22.19 - ~/.nvm/versions/node/v14.20.0/bin/yarn
      npm: 6.14.17 - ~/.nvm/versions/node/v14.20.0/bin/npm
    npmPackages:
      @tarojs/cli: 3.5.6 => 3.5.6
      @tarojs/components: 3.5.6 => 3.5.6
      @tarojs/helper: 3.5.6 => 3.5.6
      @tarojs/plugin-framework-react: 3.5.6 => 3.5.6
      @tarojs/plugin-platform-alipay: 3.5.6 => 3.5.6
      @tarojs/plugin-platform-jd: 3.5.6 => 3.5.6
      @tarojs/plugin-platform-qq: 3.5.6 => 3.5.6
      @tarojs/plugin-platform-swan: 3.5.6 => 3.5.6
      @tarojs/plugin-platform-tt: 3.5.6 => 3.5.6
      @tarojs/plugin-platform-weapp: 3.5.6 => 3.5.6
      @tarojs/react: 3.5.6 => 3.5.6
      @tarojs/router: 3.5.6 => 3.5.6
      @tarojs/runtime: 3.5.6 => 3.5.6
      @tarojs/shared: 3.5.6 => 3.5.6
      @tarojs/taro: 3.5.6 => 3.5.6
      @tarojs/taro-h5: 3.5.6 => 3.5.6
      @tarojs/webpack5-runner: 3.5.6 => 3.5.6
      babel-preset-taro: 3.5.6 => 3.5.6
      eslint-config-taro: 3.5.6 => 3.5.6
      react: ^18.0.0 => 18.2.0
Chen-jj commented 1 year ago

@gongzili456 怀疑是你的 PostCSS 配置有误,如果还有问题可以提供一下 demo

EasonMar commented 1 year ago

npx @tarojs/cli init myApp

👽 Taro v3.5.7

Taro 即将创建一个新项目! Need help? Go and open issue: https://tls.jd.com/taro-issue-helper

? 请输入项目介绍 my App ? 请选择框架 React ? 是否需要使用 TypeScript ? Yes ? 请选择 CSS 预处理器(Sass/Less/Stylus) Sass ? 请选择编译工具 Webpack5 ? 请选择包管理工具 npm ? 请选择模板源 Gitee(最快) ? 请选择模板 默认模板

SeanBurt commented 1 year ago

me too,version 3.5.7

yoyo837 commented 1 year ago

npx @tarojs/cli init myApp

👽 Taro v3.5.7

Taro 即将创建一个新项目! Need help? Go and open issue: https://tls.jd.com/taro-issue-helper

? 请输入项目介绍 my App ? 请选择框架 React ? 是否需要使用 TypeScript ? Yes ? 请选择 CSS 预处理器(Sass/Less/Stylus) Sass ? 请选择编译工具 Webpack5 ? 请选择包管理工具 npm ? 请选择模板源 Gitee(最快) ? 请选择模板 默认模板

  • 通过以上选项生成项目,不变更任何配置,能复现以上问题
  • 环境:node-v12.22.12 \ MacOs-v10.14.6
  • 命令:npm run build:weapp
  • 报错:

    • Error: pages/index/index.wxss from Css Minimizer plugin
    • Error: [object Object] is not a PostCSS plugin

image 无法重现, 请提供demo

SeanBurt commented 1 year ago

demo: https://github.com/SeanBurt/mp2h5.git

SeanBurt commented 1 year ago

用 yarn 安装依赖 可以 build 成功,用 npm 安装依赖 build 失败。 两者对比,yarn 安装的 postcss 版本是 8,npm 安装的是 6。

SeanBurt commented 1 year ago

demo: SeanBurt/mp2h5.git

@yoyo837

SeanBurt commented 1 year ago

用 yarn 安装依赖 可以 build 成功,用 npm 安装依赖 build 失败。 两者对比,yarn 安装的 postcss 版本是 8,npm 安装的是 6。

看了下依赖关系,@tarojs/cli@3.5.7 依赖 postcss@^6.0.22,但是一些 webpack 的插件依赖 postcss 版本 8,所以导致 build 失败。

yoyo837 commented 1 year ago

demo: https://github.com/SeanBurt/mp2h5.git

仓库不是一个合法的node项目, package.json都找不到. 请重新提供一个.

yoyo837 commented 1 year ago

clone 下来 安装后直接能run 看问题的

SeanBurt commented 1 year ago

demo: SeanBurt/mp2h5.git

仓库不是一个合法的node项目, package.json都找不到. 请重新提供一个.

按照 readme 操作

SeanBurt commented 1 year ago

clone 下来 安装后直接能run 看问题的

是按照 readme 操作的吗?

yoyo837 commented 1 year ago

暂时没看, 在搬砖, 如果你已经判断是postcss版本冲突, 应该可以在3.6.0中解决 https://github.com/NervJS/taro/pull/12525 https://github.com/NervJS/taro/pull/12779

jackie19 commented 1 year ago

postcss-html-transform 这个包依赖的postcss 版本是 6.0.22

yoyo837 commented 1 year ago

postcss-html-transform 这个包依赖的postcss 版本是 6.0.22

12525 已经处理了.

jackie19 commented 1 year ago

在项目目录中手动运行 npm i postcss 可以成功build

jackie19 commented 1 year ago

postcss-html-transform 这个包依赖的postcss 版本是 6.0.22

12525 已经处理了.

请问什么时候发版?npm上貌似还是3.5.7

Lazydd commented 3 months ago

@yoyo837 之前用pnpm是好的,今天重装了依赖,用pnpm也不行了,也是postcss的问题,他选了6的版本,yarn用的是8的