【问题标题】:cannot find module styles.css with postcss找不到带有 postcss 的模块 styles.css
【发布时间】:2019-01-07 01:57:34
【问题描述】:

我正在按照这个示例快速介绍 postcss:

https://www.sitepoint.com/an-introduction-to-postcss/

在全局安装postcssautoprefixer后,在我的项目根目录下创建一个styles.css文件并运行以下命令:

postcss -u autoprefixer styles.css -d public

我得到错误:

Plugin Error: Cannot find module 'styles.css'

为什么会认为是插件错误?

【问题讨论】:

    标签: postcss autoprefixer postcss-cli


    【解决方案1】:

    遇到了同样的问题并找到了这个相关的帖子:Autoprefixer errors with NPM (✖ Plugin Error: Cannot find module )

    我运行的命令是

    postcss styles.css -d dist -u autoprefixer
    

    正如相关答案所示,-u 现在需要多个插件,因此必须修改顺序。

    此外,如果您使用该教程,“display: flex;”的示例不再有用,因为它将在浏览器中“按原样”工作。而是使用

    ::placeholder {
      color: gray;
    }
    

    测试自动前缀

    【讨论】:

    • 在一个包含 100ds 的 .css 文件的项目中,如何运行此命令但用新的 css 文件替换当前的 css 文件?我试过这个:npx postcss ./src/**/*.css -d dist -u autoprefixer
    猜你喜欢
    • 2019-02-16
    • 1970-01-01
    • 2021-06-17
    • 2018-09-10
    • 1970-01-01
    • 2020-01-25
    • 1970-01-01
    • 1970-01-01
    • 2017-10-11
    相关资源
    最近更新 更多