首页 > 解决方案 > Path.replace 不是 NPM SCSS AUTOPREFIXER 构建过程的函数

问题描述

我正在尝试建立一个 sass 构建过程。基本上,压缩、连接、前缀和压缩。我对 autoprefixer 包有疑问。起初,我做不到,因为这个版本 10 有一些错误,它与 postcss 包不兼容。所以我将它降级到版本@9.8.6,这是我得到的错误。

-----PACKAGE.JSON------

{
  "name": "natouros_website_project",
  "version": "1.0.0",
  "description": "landing page for natours",
  "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": "",
  "license": "ISC",
  "devDependencies": {
    "autoprefixer": "^9.8.6",
    "concat": "^1.0.3",
    "node-sass": "^5.0.0",
    "postcss-cli": "^8.3.0"
  }
}

-----终端错误------

> natouros_website_project@1.0.0 prefix:css C:\Users\M\Desktop\natouros_website_project
> postcss --use autoprefixer -b 'last 10 versions' css/style.concat.css -o css/style.prefix.css

TypeError: path.replace is not a function
    at module.exports (C:\Users\\Desktop\natouros_website_project\node_modules\slash\index.js:10:14)
    at Array.map (<anonymous>)
    at C:\Users\\Desktop\natouros_website_project\node_modules\postcss-cli\index.js:66:28
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! natouros_website_project@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 natouros_website_project@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\\AppData\Roaming\npm-cache\_logs\2020-12-01T10_28_16_713Z-debug.log

C:\Users\Mihailo\Desktop\natouros_website_project>

如果需要,我还可以提供 debug.log。

标签: node.jsnpmsassbuild

解决方案


Windows 不识别单引号。因此,将“最近 10 个版本”周围的单引号替换为带有转义字符的双引号(“最近 10 个版本”)。

有关更多信息,请参阅以下链接 https://github.com/postcss/postcss-cli/issues/360


推荐阅读