之前一个前台项目构建都正常,昨天构建失败了,报错信息如下:

Error: [object Object] is not a PostCSS plugin
    at Processor.normalize (/root/.jenkins/workspace/web-domp-kanban/node_modules/postcss/lib/processor.js:168:15)
    at new Processor (/root/.jenkins/workspace/web-domp-kanban/node_modules/postcss/lib/processor.js:52:25)
    at postcss (/root/.jenkins/workspace/web-domp-kanban/node_modules/postcss/lib/postcss.js:55:10)
    at cssnanoPlugin (/root/.jenkins/workspace/web-domp-kanban/node_modules/cssnano/dist/index.js:137:31)
    at getDefaultProcessor (/root/.jenkins/workspace/web-domp-kanban/node_modules/optimize-css-assets-webpack-plugin/src/index.js:9:19)
    at new OptimizeCssAssetsWebpackPlugin (/root/.jenkins/workspace/web-domp-kanban/node_modules/optimize-css-assets-webpack-plugin/src/index.js:30:9)
    at Object.<anonymous> (/root/.jenkins/workspace/web-domp-kanban/webpack.prod.conf.js:50:21)
    at Module._compile (/root/.jenkins/workspace/web-domp-kanban/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
    at Module.load (internal/modules/cjs/loader.js:1049:32)
    at Function.Module._load (internal/modules/cjs/loader.js:937:14)
    at Module.require (internal/modules/cjs/loader.js:1089:19)
    at require (/root/.jenkins/workspace/web-domp-kanban/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
    at WEBPACK_OPTIONS (/root/.jenkins/workspace/web-domp-kanban/node_modules/webpack-cli/bin/utils/convert-argv.js:114:13)
    at requireConfig (/root/.jenkins/workspace/web-domp-kanban/node_modules/webpack-cli/bin/utils/convert-argv.js:116:6)
    at /root/.jenkins/workspace/web-domp-kanban/node_modules/webpack-cli/bin/utils/convert-argv.js:123:17
    at Array.forEach (<anonymous>)
    at module.exports (/root/.jenkins/workspace/web-domp-kanban/node_modules/webpack-cli/bin/utils/convert-argv.js:121:15)
    at /root/.jenkins/workspace/web-domp-kanban/node_modules/webpack-cli/bin/cli.js:71:45
    at Object.parse (/root/.jenkins/workspace/web-domp-kanban/node_modules/yargs/yargs.js:567:18)
    at /root/.jenkins/workspace/web-domp-kanban/node_modules/webpack-cli/bin/cli.js:49:8
    at Object.<anonymous> (/root/.jenkins/workspace/web-domp-kanban/node_modules/webpack-cli/bin/cli.js:366:3)
    at Module._compile (internal/modules/cjs/loader.js:1200:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
    at Module.load (internal/modules/cjs/loader.js:1049:32)
    at Function.Module._load (internal/modules/cjs/loader.js:937:14)
    at Module.require (internal/modules/cjs/loader.js:1089:19)
    at require (internal/modules/cjs/helpers.js:73:18)
    at Object.<anonymous> (/root/.jenkins/workspace/web-domp-kanban/node_modules/webpack/bin/webpack.js:156:2)
    at Module._compile (internal/modules/cjs/loader.js:1200:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
    at Module.load (internal/modules/cjs/loader.js:1049:32)
    at Function.Module._load (internal/modules/cjs/loader.js:937:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @project/web-domp-kanban@1.0.0 build-app: `webpack --progress --config webpack.prod.conf.js  --mode=production`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @project/web-domp-kanban@1.0.0 build-app 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!     /root/.npm/_logs/2021-05-18T02_24_17_917Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @project/web-domp-kanban@1.0.0 build: `npm run build-app && npm run lib`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @project/web-domp-kanban@1.0.0 build 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!     /root/.npm/_logs/2021-05-18T02_24_17_928Z-debug.log
Build step '执行 shell' marked build as failure
SSH: Current build result is [FAILURE], not going to run.
Finished: FAILURE

 一直没有找到是什么情况导致这个报错,今天看到这个报错前面有一段warn信息:

found 1182 vulnerabilities (596 low, 23 moderate, 563 high)
  run `npm audit fix` to fix them, or `npm audit` for details
+ npm install
npm WARN css-declaration-sorter@6.0.0 requires a peer of postcss@^8.0.9 but none is installed. You must install peer dependencies yourself.
npm WARN cssnano@5.0.2 requires a peer of postcss@^8.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN cssnano-preset-default@5.0.1 requires a peer of postcss@^8.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN cssnano-utils@2.0.0 requires a peer of postcss@^8.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-vue-libs@3.0.2 requires a peer of eslint@^4.7.0 but none is installed. You must install peer dependencies yourself.
npm WARN postcss-calc@8.0.0 requires a peer of postcss@^8.2.2 but none is installed. You must install peer dependencies yourself.
npm WARN postcss-colormin@5.0.0 requires a peer of postcss@^8.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN postcss-convert-values@5.0.0 requires a peer of postcss@^8.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN postcss-discard-comments@5.0.0 requires a peer of postcss@^8.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN postcss-discard-duplicates@5.0.0 requires a peer of postcss@^8.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN postcss-discard-empty@5.0.0 requires a peer of postcss@^8.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN postcss-discard-overridden@5.0.0 requires a peer of postcss@^8.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN postcss-merge-longhand@5.0.1 requires a peer of postcss@^8.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN postcss-merge-rules@5.0.0 requires a peer of postcss@^8.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN postcss-minify-font-values@5.0.0 requires a peer of postcss@^8.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN postcss-minify-gradients@5.0.0 requires a peer of postcss@^8.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN postcss-minify-params@5.0.0 requires a peer of postcss@^8.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN postcss-minify-selectors@5.0.0 requires a peer of postcss@^8.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN postcss-normalize-charset@5.0.0 requires a peer of postcss@^8.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN postcss-normalize-display-values@5.0.0 requires a peer of postcss@^8.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN postcss-normalize-positions@5.0.0 requires a peer of postcss@^8.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN postcss-normalize-repeat-style@5.0.0 requires a peer of postcss@^8.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN postcss-normalize-string@5.0.0 requires a peer of postcss@^8.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN postcss-normalize-timing-functions@5.0.0 requires a peer of postcss@^8.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN postcss-normalize-unicode@5.0.0 requires a peer of postcss@^8.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN postcss-normalize-url@5.0.0 requires a peer of postcss@^8.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN postcss-normalize-whitespace@5.0.0 requires a peer of postcss@^8.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN postcss-ordered-values@5.0.0 requires a peer of postcss@^8.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN postcss-reduce-initial@5.0.0 requires a peer of postcss@^8.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN postcss-reduce-transforms@5.0.0 requires a peer of postcss@^8.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN postcss-svgo@5.0.0 requires a peer of postcss@^8.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN postcss-unique-selectors@5.0.0 requires a peer of postcss@^8.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN stylehacks@5.0.0 requires a peer of postcss@^8.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN The package babel-plugin-jsx-v-model is included as both a dev and production dependency.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

 于是在构建命令中增加了安装8.2.1版本的postcss的脚本,完整构建命令如下:

cd /root/.jenkins/workspace/web-domp-kanban   #进入项目目录
npm install chromedriver --chromedriver_cdnurl=http://cdn.npm.taobao.org/dist/chromedriver
npm install postcss@8.2.1
npm install optimize-css-assets-webpack-plugin --save-dev
npm install 
npm run build

这个突然postcss报错的原因通过这个方式解决了,但是为什么会出现这个报错的原因还没查明,我猜测是否构建其他项目更改了postcss版本导致的

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐