【问题标题】:index.css:undefined:undefined: plugin is not a functionindex.css:undefined:undefined: 插件不是函数
【发布时间】:2022-07-21 05:02:18
【问题描述】:

我正在尝试MDN Front End Developer courseUnderstanding client-side web development tools 模块的Introducing a complete toolchain 章节。我已经到达最后的运行转换部分,说明建议运行npx parcel src/index.html。在这个阶段我遇到了两个问题。

  • build 进程卡在Building scheduler-tracing.development.js。在多次中止尝试后,我让它运行了 6 个小时,然后中止。
  • 中止进程并重新运行后,我收到以下错误:
/home/username/dev/will-it-miss/src/index.css:undefined:undefined: plugin is not a function
at LazyResult.run (/home/username/dev/will-it-miss/node_modules/parcel-bundler/node_modules/postcss/lib/lazy-result.js:288:14)
at LazyResult.asyncTick (/home/username/dev/will-it-miss/node_modules/parcel-bundler/node_modules/postcss/lib/lazy-result.js:212:26)
at /home/username/dev/will-it-miss/node_modules/parcel-bundler/node_modules/postcss/lib/lazy-result.js:254:14
at new Promise (<anonymous>)
at LazyResult.async (/home/username/dev/will-it-miss/node_modules/parcel-bundler/node_modules/postcss/lib/lazy-result.js:250:23)
at LazyResult.then (/home/username/dev/will-it-miss/node_modules/parcel-bundler/node_modules/postcss/lib/lazy-result.js:131:17)

作为开发新手,我在解决此错误方面运气不佳,但目前采取的措施如下:

  • index.js script 类型设置为模块,并按照MDN Discourse forum 上此线程中的建议更新了SVG 路径。
  • 将 index.css 中的 postcss 特定嵌套选择器替换为常规选择器
  • 将 postcss 的项目版本恢复到以前的版本
  • 从头开始删除并重建项目 5~ 次并获得相同的结果(卡住 building scheduler-tracing.development.js、中止进程、重新运行以及与上述 index.css 相关的错误。

另一个用户报告了与我在链接论坛帖子中显示的相同的错误。如果有任何其他信息可能有助于解决此错误,请告诉我。

【问题讨论】:

    标签: javascript


    【解决方案1】:

    尝试以下方法:

    1. 运行以下命令安装兼容版本 postcss-preset-env

    2. npm install --save-dev postcss-preset-env@6.7.0 将一个名为 .postcssrc.json 的文件添加到项目目录的根目录。

    3. 将以下内容添加到新文件中,这将自动 让我们完全访问最新的 CSS 功能:

      { "plugins": { "postcss-preset-env": { "stage": 0 } } }

    4. 附加 .json(这个对我有用)或 .yml 文件扩展名 .postcssrc 文件。

    5. 再次运行npx parcel index.html 命令。

    参考资料:

    Github, Inc. “引入完整工具链”的问题:构建失败; postcss-preset-env 版本的问题 #12495。 https://github.com/mdn/content/issues/12495#issuecomment-1025004164。 (2022 年 7 月 20 日访问)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-07-29
      • 1970-01-01
      • 2018-02-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-05
      • 2011-01-07
      相关资源
      最近更新 更多