[Tencent/weui]引入了2.1.3版本,打包的时候报错

2023-12-14 825 views
8

building for production...Error processing file: static/css/app.961533fc18508d1a5b4a6edc8cbf30aa.css (node:40432) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 15): TypeError: Cannot read property 'toFixed' of undefined (node:40432) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. 引入了2.1.3版本,打包的时候报错

回答

9

@dantine123 @lqtcts 能否把报错日志整个打出来看看?

7

ERROR in ./node_modules/weui/dist/style/weui.css Module build failed: ModuleBuildError: Module build failed: TypeError: Cannot read property 'toFixed' of undefined at strongRound (F:\tkw-hrc-ued\dlls\node_modules\svgo\plugins\convertPathData.js:766:21) at F:\tkw-hrc-ued\dlls\node_modules\svgo\plugins\convertPathData.js:424:17 at Array.filter () at filters (F:\tkw-hrc-ued\dlls\node_modules\svgo\plugins\convertPathData.js:272:17) at Object.exports.fn (F:\tkw-hrc-ued\dlls\node_modules\svgo\plugins\convertPathData.js:79:20) at F:\tkw-hrc-ued\dlls\node_modules\svgo\lib\svgo\plugins.js:59:45 at Array.filter () at monkeys (F:\tkw-hrc-ued\dlls\node_modules\svgo\lib\svgo\plugins.js:46:39) at F:\tkw-hrc-ued\dlls\node_modules\svgo\lib\svgo\plugins.js:66:17 at Array.filter () at monkeys (F:\tkw-hrc-ued\dlls\node_modules\svgo\lib\svgo\plugins.js:46:39) at perItem (F:\tkw-hrc-ued\dlls\node_modules\svgo\lib\svgo\plugins.js:77:12) at F:\tkw-hrc-ued\dlls\node_modules\svgo\lib\svgo\plugins.js:18:24 at Array.forEach () at module.exports (F:\tkw-hrc-ued\dlls\node_modules\svgo\lib\svgo\plugins.js:14:13) at F:\tkw-hrc-ued\dlls\node_modules\svgo\lib\svgo.js:63:17 at SAXParser.sax.onend (F:\tkw-hrc-ued\dlls\node_modules\svgo\lib\svgo\svg2js.js:156:13) at emit (F:\tkw-hrc-ued\dlls\node_modules\sax\lib\sax.js:624:35) at end (F:\tkw-hrc-ued\dlls\node_modules\sax\lib\sax.js:667:5) at SAXParser.write (F:\tkw-hrc-ued\dlls\node_modules\sax\lib\sax.js:975:14) at SAXParser.close (F:\tkw-hrc-ued\dlls\node_modules\sax\lib\sax.js:157:38) at module.exports (F:\tkw-hrc-ued\dlls\node_modules\svgo\lib\svgo\svg2js.js:169:28) at module.exports.SVGO._optimizeOnce (F:\tkw-hrc-ued\dlls\node_modules\svgo\lib\svgo.js:56:5) at module.exports.SVGO.optimize (F:\tkw-hrc-ued\dlls\node_modules\svgo\lib\svgo.js:49:11) at F:\tkw-hrc-ued\dlls\node_modules\postcss-svgo\dist\index.js:64:25 at new Promise () at F:\tkw-hrc-ued\dlls\node_modules\postcss-svgo\dist\index.js:63:23 at walk (F:\tkw-hrc-ued\dlls\node_modules\postcss-value-parser\lib\walk.js:7:16) at ValueParser.walk (F:\tkw-hrc-ued\dlls\node_modules\postcss-value-parser\lib\index.js:18:3) at minifyPromise (F:\tkw-hrc-ued\dlls\node_modules\postcss-svgo\dist\index.js:33:64) at runLoaders (F:\tkw-hrc-ued\dlls\node_modules\webpack\lib\NormalModule.js:195:19) at F:\tkw-hrc-ued\dlls\node_modules\loader-runner\lib\LoaderRunner.js:367:11 at F:\tkw-hrc-ued\dlls\node_modules\loader-runner\lib\LoaderRunner.js:233:18 at context.callback (F:\tkw-hrc-ued\dlls\node_modules\loader-runner\lib\LoaderRunner.js:111:13) at Object. (F:\tkw-hrc-ued\dlls\node_modules\css-loader\lib\loader.js:50:18) at F:\tkw-hrc-ued\dlls\node_modules\css-loader\lib\processCss.js:236:4 at process._tickCallback (internal/process/next_tick.js:68:7) @ ./node_modules/weui/dist/style/weui.css @ ./src/weui/index.js

ERROR in ./node_modules/css-loader!./node_modules/weui/dist/style/weui.css Module build failed: TypeError: Cannot read property 'toFixed' of undefined at strongRound (F:\tkw-hrc-ued\dlls\node_modules\svgo\plugins\convertPathData.js:766:21) at F:\tkw-hrc-ued\dlls\node_modules\svgo\plugins\convertPathData.js:424:17 at Array.filter () at filters (F:\tkw-hrc-ued\dlls\node_modules\svgo\plugins\convertPathData.js:272:17) at Object.exports.fn (F:\tkw-hrc-ued\dlls\node_modules\svgo\plugins\convertPathData.js:79:20) at F:\tkw-hrc-ued\dlls\node_modules\svgo\lib\svgo\plugins.js:59:45 at Array.filter () at monkeys (F:\tkw-hrc-ued\dlls\node_modules\svgo\lib\svgo\plugins.js:46:39) at F:\tkw-hrc-ued\dlls\node_modules\svgo\lib\svgo\plugins.js:66:17 at Array.filter () at monkeys (F:\tkw-hrc-ued\dlls\node_modules\svgo\lib\svgo\plugins.js:46:39) at perItem (F:\tkw-hrc-ued\dlls\node_modules\svgo\lib\svgo\plugins.js:77:12) at F:\tkw-hrc-ued\dlls\node_modules\svgo\lib\svgo\plugins.js:18:24 at Array.forEach () at module.exports (F:\tkw-hrc-ued\dlls\node_modules\svgo\lib\svgo\plugins.js:14:13) at F:\tkw-hrc-ued\dlls\node_modules\svgo\lib\svgo.js:63:17 at SAXParser.sax.onend (F:\tkw-hrc-ued\dlls\node_modules\svgo\lib\svgo\svg2js.js:156:13) at emit (F:\tkw-hrc-ued\dlls\node_modules\sax\lib\sax.js:624:35) at end (F:\tkw-hrc-ued\dlls\node_modules\sax\lib\sax.js:667:5) at SAXParser.write (F:\tkw-hrc-ued\dlls\node_modules\sax\lib\sax.js:975:14) at SAXParser.close (F:\tkw-hrc-ued\dlls\node_modules\sax\lib\sax.js:157:38) at module.exports (F:\tkw-hrc-ued\dlls\node_modules\svgo\lib\svgo\svg2js.js:169:28) at module.exports.SVGO._optimizeOnce (F:\tkw-hrc-ued\dlls\node_modules\svgo\lib\svgo.js:56:5) at module.exports.SVGO.optimize (F:\tkw-hrc-ued\dlls\node_modules\svgo\lib\svgo.js:49:11) at F:\tkw-hrc-ued\dlls\node_modules\postcss-svgo\dist\index.js:64:25 at new Promise () at F:\tkw-hrc-ued\dlls\node_modules\postcss-svgo\dist\index.js:63:23 at walk (F:\tkw-hrc-ued\dlls\node_modules\postcss-value-parser\lib\walk.js:7:16) at ValueParser.walk (F:\tkw-hrc-ued\dlls\node_modules\postcss-value-parser\lib\index.js:18:3) at minifyPromise (F:\tkw-hrc-ued\dlls\node_modules\postcss-svgo\dist\index.js:33:64) @ ./node_modules/weui/dist/style/weui.css 4:14-66 @ ./src/weui/index.js

大佬帮忙看一下@BearJ

1

@fengyunchangxuan @geekgray 抱歉回复晚了,试试把 svgo 关掉看看?

image

5

@lollipop7 在webpack的配置文件里,如果是vue-cli生成的项目,试试这样:

// vue.config.js
module.exports = {
  chainWebpack: config => {
    config.plugin('optimize-css').tap(([options]) => {
      options.cssnanoOptions.preset[1].svgo = false
      return [options]
    })
  }
}
5

@BearJ vue init生成的项目,后来放弃使用weui了,谢谢回复

0

ERROR in ./node_modules/weui/dist/style/weui.css Module build failed: ModuleBuildError: Module build failed: TypeError: Cannot read property 'toFixed' of undefined at strongRound (F:\tkw-hrc-ued\dlls\node_modules\svgo\plugins\convertPathData.js:766:21) 看这个错误,很显然是这个包里的文件convertPathData出的问题,一般来说,如果批量引入了,但是又确实没用到,不会配置打包的话,可以直接找到node_modules里去,屏蔽toFixed就可以了。 这种方式也适用于任何此类打包错误,因为一些没用到的内容去试各种打包配置感觉没必要。