首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法在npm脚本中正确配置自动重定位程序

无法在npm脚本中正确配置自动重定位程序
EN

Stack Overflow用户
提问于 2020-09-18 18:28:15
回答 1查看 986关注 0票数 0

我正在尝试配置PostCSS自动修复程序,但它不起作用。它应该在同一个'css‘文件夹中输出新的style.prefix.css文件。请帮助我理解,我的npm脚本/设置有什么问题?

这是我的package.json

代码语言:javascript
复制
{
  "name": "sb-demo-website",
  "version": "1.0.0",
  "description": "demo website",
  "main": "index.js",
  "scripts": {
    "sass": "node-sass-chokidar sass/main.scss css/style.css -w --recursive --skip-initial",
    "compile-sass": "node-sass-chokidar sass/main.scss css/style.comp.css",
    "prefix-css": "postcss css/style.comp.css -o css/style.prefix.css --use autoprefixer"
  },
  "repository": {
    "type": "git",
    "url": ""
  },
  "author": "tk",
  "license": "ISC",
  "bugs": {
    "url": ""
  },
  "homepage": "",
  "browserslist": "last 3 versions",
  "devDependencies": {
    "autoprefixer": "^10.0.0",
    "node-sass": "^4.14.1",
    "node-sass-chokidar": "^1.5.0",
    "postcss": "^8.0.5",
    "postcss-cli": "^7.1.2"
  }
}

下面是我运行脚本时的输出:

代码语言:javascript
复制
$ npm run prefix-css

> sb-demo-website@1.0.0 prefix-css C:\Users\tk\Documents\Study\web\css\demo1
> postcss css/style.comp.css -o css/style.prefix.css --use autoprefixer

Error: PostCSS plugin autoprefixer requires PostCSS 8. Update PostCSS or downgrade this plugin.
    at Processor.normalize (C:\Users\tk\Documents\Study\web\css\demo1\node_modules\postcss-cli\node_modules\postcss\lib\processor.js:167:15)
    at new Processor (C:\Users\tk\Documents\Study\web\css\demo1\node_modules\postcss-cli\node_modules\postcss\lib\processor.js:56:25)
    at postcss (C:\Users\tk\Documents\Study\web\css\demo1\node_modules\postcss-cli\node_modules\postcss\lib\postcss.js:55:10)
    at C:\Users\tk\Documents\Study\web\css\demo1\node_modules\postcss-cli\index.js:216:14
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sb-demo-website@1.0.0 prefix-css: `postcss css/style.comp.css -o css/style.prefix.css --use autoprefixer`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sb-demo-website@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\tk\AppData\Roaming\npm-cache\_logs\2020-09-18T17_50_55_597Z-debug.log

任何帮助都非常感谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-09-18 21:57:27

现在看来,最新的自动修复程序v10.0.0有点像坏的。将其降级到9.8.6版本解决了上述问题。

我将此作为一个答案,以防其他人遇到类似的错误。

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63961009

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档