错误:PostCSS 插件自动前缀需要 PostCSS 8.更新 PostCSS 或降级此插件 [英] Error: PostCSS plugin autoprefixer requires PostCSS 8. Update PostCSS or downgrade this plugin

查看:2301
本文介绍了错误:PostCSS 插件自动前缀需要 PostCSS 8.更新 PostCSS 或降级此插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次运行 npm start 时都会收到此错误.我尝试了几个修复程序,但没有一个对我有用.我尝试将 autoprefixer 的版本更改为 9.8.6,但是没有用.请帮我解决这个问题

I am getting this error whenever I run npm start. I tried a couple of fixes but none of them work for me. I tried to change the version of autoprefixer to 9.8.6 but it didn't work. Please help me with this issue

这是我的 package.json

This is my package.json

{
  "name": "reactgallery",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.5.0",
    "@testing-library/user-event": "^7.2.1",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-scripts": "3.4.3"
  },
  "scripts": {
    "start": "npm run watch:css && react-scripts start",
    "build": "npm run build:css && react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "build:css": "postcss src/assets/tailwind.css -o src/assets/main.css",
    "watch:css": "postcss src/assets/tailwind.css -o src/assets/main.css"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "autoprefixer": "^9.8.6",
    "postcss-cli": "^7.1.2",
    "tailwindcss": "^1.8.10"
  }
}

推荐答案

快速修复

将您的自动前缀降级到版本 9,使用

Quick fix

Downgrade your autoprefixer to version 9, use

自动前缀":^9.0.0"

"autoprefixer": "^9.0.0"

在您的开发依赖项中.

PostCSS 已更新到第 8 版,但是,PostCSS CLI 尚未更新以处理使用新 PostCSS 8+ API 的 PostCSS 插件.Autoprefixer 使用自 10 版以来的新 PostCSS 8 API.

PostCSS was updated to version 8, however, PostCSS CLI has not yet been updated to handle PostCSS plugins which use the new PostCSS 8+ API. Autoprefixer uses the new PostCSS 8 API since version 10.

这记录在 PostCSS 中的已知问题 GitHub 页面.

This is documented under known issues in the PostCSS GitHub page.

一旦 PostCSS CLI 更新为处理使用新 PostCSS 8+ API 的插件,这可能就不是问题.但在那之前,你可能需要降级一些 PostCSS 插件以避免错误.

Once PostCSS CLI is updated to handle plugins that use the new PostCSS 8+ API, this will likely not be an issue. But until then, you may need to downgrade some PostCSS plugins to avoid errors.

这篇关于错误:PostCSS 插件自动前缀需要 PostCSS 8.更新 PostCSS 或降级此插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆