Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find module 'autoprefixer' when running npx tailwindcss init -p command

I'm using Vue 3 and trying to add tailwindcss into it from the following tutorial. https://tailwindcss.com/docs/guides/vue-3-vite#install-tailwind-via-npm

I have installed the dependencies using the following command,

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

But when I tried to create the configuration files using the following command

npx tailwindcss init -p

It is giving me the following error.

npx: installed 83 in 5.2s Cannot find module 'autoprefixer' Require stack:

  • /~/.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

I don't know why autoprefixer is not detecting because I have already installed it. Even the package.json have it.

{
  "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"
  ]
}
like image 330
Asif Mushtaq Avatar asked Dec 11 '20 22:12

Asif Mushtaq


People also ask

Can we use Tailwind CSS in react native?

tailwind function returns a simple object with styles, which can be used in any React Native view, such as <View> , <Text> and others.

What is Tailwind CSS line clamp?

A plugin that provides utilities for visually truncating text after a fixed number of lines.

Does tailwind use PostCSS?

By default, it uses the postcss-nested plugin under the hood, which uses a Sass-like syntax and is the plugin that powers nesting support in the Tailwind CSS plugin API.


2 Answers

Run:

npx tailwindcss-cli@latest init -p
like image 153
Abdi Nur Avatar answered Sep 19 '22 03:09

Abdi Nur


Please uninstall run this command:

npm uninstall tailwindcss postcss autoprefixer

After this module is uninstall, please run this command:

npm install tailwindcss@latest postcss@latest autoprefixer@latest
like image 21
Racal Avatar answered Sep 20 '22 03:09

Racal