包裹构建失败`bundle.scss:undefined:undefined: plugin is not a function`

cha*_*mit 1 sass reactjs postcss parceljs

我正在为我的学习项目使用包裹打包器并尝试为其创建构建。我也在使用 scss 文件。在bundle.scss我已经导入了我所有的 scss 文件。并导入bundle.scssApp.js.

所以在运行时parcel build index.html,我收到以下错误。

  /src/style/bundle.scss:undefined:undefined: plugin is not a function
    at LazyResult.run (/usr/local/lib/node_modules/parcel-bundler/node_modules/postcss/lib/lazy-result.js:288:14)
    at LazyResult.asyncTick (/usr/local/lib/node_modules/parcel-bundler/node_modules/postcss/lib/lazy-result.js:212:26)
    at /usr/local/lib/node_modules/parcel-bundler/node_modules/postcss/lib/lazy-result.js:254:14
    at new Promise (<anonymous>)
    at LazyResult.async (/usr/local/lib/node_modules/parcel-bundler/node_modules/postcss/lib/lazy-result.js:250:23)
    at LazyResult.then (/usr/local/lib/node_modules/parcel-bundler/node_modules/postcss/lib/lazy-result.js:131:17)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! xxxxx complete: `parcel build index.html`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the xxxxx complete 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!     /.npm/_logs/2021-06-12T17_37_55_156Z-debug.log
Run Code Online (Sandbox Code Playgroud)

我的项目结构

src/
-App.js
-styles/
--bundle.scss
--app.scss
-index.html

Run Code Online (Sandbox Code Playgroud)

任何建议对我来说都是真正的帮助,谢谢。

Kok*_*oko 7

这似乎是 Parcel 的一个错误nanocss。我只能通过根本不缩小 css 来修复它,使用

parcel build --no-minify
Run Code Online (Sandbox Code Playgroud)

  • 这似乎是旧版本的问题,使用新的“npm i Parcel”这个问题似乎已经解决。 (2认同)

Jac*_*ana 6

你不必删除你的缩小,还有另一种方法..

你看不到,cssnano version因为它在引擎盖下。parcel bundler versioncurrent和 current存在错误cssnano version

你可以通过降级 cssnano 来解决这个问题

npm uninstall cssnano
npm i -D cssnano@4.1.11
Run Code Online (Sandbox Code Playgroud)

现在尝试用 重建它parcel build <your path>,它应该可以工作。