【问题标题】:Autoprefixer errors with NPM (✖ Plugin Error: Cannot find module )NPM 的自动前缀错误(✖ 插件错误:找不到模块)
【发布时间】:2017-08-30 20:08:45
【问题描述】:

所以目前我在使用 autoprefixer 时遇到了问题。

我已将 postcss-cli 和 autoprefixer 下载到 --save-dev 和 -g

当我运行这样的命令时:

postcss ../../../htdocs/css/workflow/homepage-announcements.css -o ../../../htdocs/css/workflow/homepage-announcements.css

适用于以下输出:

✔ 完成 ../../../htdocs/css/workflow/homepage-announcements.css (25ms)

现在我使用了--use autoprefixer 会引发错误。下面的命令。

postcss --use autoprefixer ../../../htdocs/css/workflow/homepage-announcements.css -o ../../../htdocs/css/workflow/homepage-announcements.css

错误信息:

✖插件错误:找不到模块'../../../htdocs/css/workflow/homepage-announcements.css'

我已经尝试了所有方法,但仍然没有解决方案:(

{
    "name": "homepage-announcements",
    "version": "2.0.0",
    "description": "Homepage announcements",
    "main": "js/Default.js",
    "dependencies": {
       "react": "^15.4.2"
     },
    "devDependencies": {
    "autoprefixer": "^6.7.7",
    "ava": "^0.18.2",
    "babel-loader": "^6.4.1",
    "eslint": "^3.19.0",
    "node-sass": "^4.5.2",
    "postcss": "^5.2.16",
    "postcss-cli": "^3.1.1",
    "webpack": "^2.3.3",
    "xo": "^0.18.1"
    },
    "scripts": {

    "build": "webpack -p && npm run sass && npm run css",
    "sass": "node-sass scss/default.scss ../../../htdocs/css/workflow/homepage-announcements.css --output-style compressed && npm run css",
    "css": "postcss --use autoprefixer ../../../htdocs/css/workflow/homepage-announcements.css -o ../../../htdocs/css/workflow/homepage-announcements.css",
    "lint": "xo js/*.js js/**/*.js js/**/**/*.js js/**/**/**/*.js js/**/**/**/**/*.js js/**/**/**/**/**/*.js"
}

【问题讨论】:

    标签: npm autoprefixer postcss-cli


    【解决方案1】:

    我有同样的问题,结果输入参数改变了位置。

    我曾经这样做过,并且成功了:

    postcss --replace --use autoprefixer file.css
    

    ...但是现在它认为file.css 是一个插件,因为--use 需要一个插件数组。

    你现在必须这样做:

    postcss file.css --replace --use autoprefixer
    

    【讨论】:

      【解决方案2】:

      "prefix:css": "postcss --use autoprefixer -b 'last 10 versions' css/style.concat.css -o css/style.prefix.css"

      我只是更改下面代码中给出的 'prefix: css' #autoprefixer :"^9.8.5" 行并删除 -b 'last 10 version' 代码,所以我的命令运行成功。

      "prefix:css": "postcss css/style.concat.css -o css/style.prefix.css --use autoprefixer

      【讨论】:

        【解决方案3】:

        package.json 文件中添加给定脚本并在终端中运行该脚本:

        "prefix:css": "postcss --use autoprefixer -o css/style.prefix.css css/style.concat.css"
        

        【讨论】:

          【解决方案4】:

          下载跨环境的自动前缀对我有用:

          npm install autoprefixer@latest cross-env --save-dev
          

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2014-12-29
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2019-08-03
            • 1970-01-01
            • 2017-01-17
            相关资源
            最近更新 更多