运行npx tawincss init-p命令时找不到模块'自动修复程序

2022-04-07 00:00:00 css vue.js npm tailwind-css vuejs3

我正在使用Vue 3,并尝试从下面的教程中向其中添加Tail Windcss。https://tailwindcss.com/docs/guides/vue-3-vite#install-tailwind-via-npm

我已使用以下命令安装了依赖项

npm install -D tailwindcss@npm:@tailwindcss/postcss7-compat postcss@^7 autoprefixer@^9

但当我尝试使用以下命令创建配置文件时

npx tailwindcss init -p

它给我显示以下错误。

Npx:5.2s中安装的83找不到所需的‘autoprefix’模块 堆栈:

  • /~/.npm/_npx/33283/lib/node_modules/tailwindcss/lib/cli/commands/build.js
  • /~/.npm/_npx/33283/lib/node_modules/tailwindcss/lib/cli/commands/index.js
  • /~/.npm/_npx/33283/lib/node_modules/tailwindcss/lib/cli/main.js
  • /~/.npm/_npx/33283/lib/node_modules/tailwindcss/lib/cli.js
我不知道为什么autoprefixer没有检测到,因为我已经安装了它。 就连Package.json都有。

{
  "name": "wooclime",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "core-js": "^3.6.5",
    "vue": "^3.0.0"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "~4.5.0",
    "@vue/cli-plugin-eslint": "~4.5.0",
    "@vue/cli-service": "~4.5.0",
    "@vue/compiler-sfc": "^3.0.0",
    "autoprefixer": "^9.8.6",
    "babel-eslint": "^10.1.0",
    "eslint": "^6.7.2",
    "eslint-plugin-vue": "^7.0.0-0",
    "postcss": "^7.0.35",
    "tailwindcss": "npm:@tailwindcss/postcss7-compat@^2.0.2"
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/vue3-essential",
      "eslint:recommended"
    ],
    "parserOptions": {
      "parser": "babel-eslint"
    },
    "rules": {}
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not dead"
  ]
}

解决方案

运行:

npx tailwindcss-cli@latest init -p

相关文章