【问题标题】:Autoprefixer script doesn't run TypeError: Patterns must be a string or an array of strings [duplicate]Autoprefixer 脚本不运行 TypeError:模式必须是字符串或字符串数​​组 [重复]
【发布时间】:2020-05-15 13:03:11
【问题描述】:

我成功安装了 autoprefixer 和 postcss-cli。我正在尝试使用我的命令提示符和 VS 代码“使用 NPM 脚本设置简单的构建过程”。我正在观看有关 CSS/SASS 主题的教程,因为我只有 2 个月的编码经验并且不太了解如何调试。我完成了我想要的代码,现在我正在尝试将所有内容编译成一个压缩的 style.css 文档......我成功地连接了所有内容,但现在我遇到了前缀问题。

在命令提示符中,我正在输入:npm run prefix:css,它正在运行此脚本: postcss --use autoprefixer -b 'last 10 versions' css/style.concat.css -o css/style.prefix.css

我明白了:

TypeError: Patterns must be a string or an array of strings 
 at assertPatternsInput (C:\Users\mjpry\Desktop\advanced-css-course master\Natours\starter\node_modules\globby\index.js:17:9)
    at generateGlobTasks (C:\Users\mjpry\Desktop\advanced-css-course-master\Natours\starter\node_modules\globby\index.js:42:2)
    at module.exports (C:\Users\mjpry\Desktop\advanced-css-course-master\Natours\starter\node_modules\globby\index.js:116:20)
    at C:\Users\mjpry\Desktop\advanced-css-course-master\Natours\starter\node_modules\postcss-cli\index.js:59:14
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! natours@1.0.0 prefix:css: `postcss --use autoprefixer -b 'last 10 versions' css/style.concat.css -o css/style.prefix.css`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the natours@1.0.0 prefix:css script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\mjpry\AppData\Roaming\npm-cache\_logs\2020-01-29T23_00_22_951Z-debug.log

就像我说的......没有足够的经验来解决这个问题。我怀疑这不是 Node_Modules 的问题,就像这个错误似乎正在捕获的那样......但我不知道该怎么做。请帮忙!

Screenshot of errors

【问题讨论】:

标签: css npm sass postcss autoprefixer


【解决方案1】:

如果您使用的是 Windows(并且按照路径显示的方式进行操作),请尝试以下操作:

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

发件人:https://github.com/npm/npm/issues/20048

【讨论】:

  • 好吧...那行得通。所以 windows 只是不理解单引号?我很感激!显然我也需要提高我的搜索技巧。
猜你喜欢
  • 2019-11-29
  • 2020-05-05
  • 2019-11-04
  • 2020-09-11
  • 1970-01-01
  • 2020-10-27
  • 1970-01-01
  • 2018-09-16
  • 2021-11-13
相关资源
最近更新 更多