【问题标题】:Autoprefixer in npm script show TypeError: Patterns must be a string or an array of stringsnpm 脚本中的自动前缀显示 TypeError:模式必须是字符串或字符串数​​组
【发布时间】:2019-11-29 00:46:12
【问题描述】:

当我运行 npm run prefix:css 时,它会显示

TypeError:模式必须是字符串或字符串数​​组

{
  "name": "natours",
  "version": "1.0.0",
  "description": "A natours project",
  "main": "index.js",
  "scripts": {
    "watch:sass": "node-sass sass/main.scss css/style.css -w",
    "compile:sass": "node-sass sass/main.scss css/style.comp.css",
    "concat:css": "concat -o css/style.concat.css css/icon-font.css 
                   css/style.comp.css",
    "prefix:css": "postcss --use autoprefixer -b 'last 10 versions' 
                   css/style.concat.css -o css/style.prefix.css"
   },
   "author": "Rahmat",
   "license": "ISC",
   "devDependencies": {
      "autoprefixer": "^9.6.1",
      "concat": "^1.0.3",
      "node-sass": "^4.12.0",
      "postcss-cli": "^6.1.3"
    }
   }

这是我的 packge.json 文件

错误图片是 -

我该如何解决?

【问题讨论】:

    标签: css npm sass


    【解决方案1】:

    "prefix:css": "postcss --use autoprefixer -b \"最近 10 个版本\" css/style.comp.css -o css/style.prefix.css",

    我认为您需要使用字符串尝试...

    【讨论】:

    • 必须使用双引号而不是单引号。这甚至包括试图转义单引号 --> 不起作用。这让我呆了几个小时。
    【解决方案2】:

    试试这个:

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

    只需删除10,它就可以正常工作。

    【讨论】:

      猜你喜欢
      • 2020-05-15
      • 2020-05-05
      • 2019-11-04
      • 2020-10-27
      • 2020-09-11
      • 1970-01-01
      • 2021-11-13
      • 2018-09-14
      • 1970-01-01
      相关资源
      最近更新 更多