【问题标题】:Autoprefixer command not found找不到自动前缀命令
【发布时间】:2021-03-19 21:36:58
【问题描述】:

我在使用 Autoprefixer 时遇到问题 我尝试使用安装:

npm install -g autoprefixer

我尝试只在我的项目中安装它:

npm install autoprefixer --save-dev

但似乎没有任何帮助。每次我得到错误:

-bash: autoprefixer: command not found

我正在使用 OSX Yosemite、node v4.1.1 和 npm v3.3.4。

请注意,我并没有尝试将 Autoprefixer 用于 Gulp 或 Grunt,而是尝试进行设置,使其作为 npm 脚本运行(如 here 所述)。

如果您需要任何其他信息,请直接询问,我会提供所需的任何东西。这令人沮丧,我花了 2 个小时试图修复它,但没有任何运气。

感谢所有聪明的答案!

【问题讨论】:

    标签: node.js bash npm autoprefixer


    【解决方案1】:

    autoprefixer 的 cli 工具已弃用。 不过仍然有一个单独的包提供它。

    您可以使用 postcss-cli 从 CLI 运行 Autoprefixer:

    npm install --global postcss-cli autoprefixer
    postcss --use autoprefixer *.css -d build/
    

    请参阅 postcss -h 以获得帮助。

    【讨论】:

    • 我无法安装包 postcss-cli。解析json失败
    【解决方案2】:

    我第一次安装时遇到了错误-

    npm install postcss-cli --save-dev
    

    在我运行此命令时安装后 -

    postcss --use autoprefixer -o css/output.css css/main.css
    

    我收到了这个错误 -

    bash: postcss: 找不到命令

    然后我尝试全局运行 -

    npm install --global postcss-cli autoprefixer
    

    在那之后我安装了一些对等依赖项 - postcss & postcss-reporter

    最后我运行这个 postcss 命令:

    postcss --use autoprefixer -o css/output.css css/main.css

    并且成功了。我希望这会有所帮助

    【讨论】:

      猜你喜欢
      • 2018-03-06
      • 2020-09-10
      • 1970-01-01
      • 1970-01-01
      • 2021-09-11
      • 1970-01-01
      • 1970-01-01
      • 2021-05-31
      • 2021-04-04
      相关资源
      最近更新 更多