2

I don't know why but when I install Tailwind in my brand new empty Next.js project I get this error after running npm run dev.

ERROR

error - ./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet1.rules[3].oneOf[11].use1!./node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet1.rules[3].oneOf[11].use[2]!./styles/globals.css /Users/andregomes/Desktop/Note/todo/tailwind.config.js:6

SyntaxError: Invalid or unexpected token Import trace for requested module: ./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet1.rules[3].oneOf[11].use1!./node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet1.rules[3].oneOf[11].use[2]!./styles/globals.css ./styles/globals.css

The best answer I found for this issue was in this Next.js discussion thread, but I already checked and I don't use tailwindcss/nesting. I just followed the regular installation instructions for Next.js and Tailwind.

tailwind.config.js

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
    "./pages/**/*.{js,ts,jsx,tsx}",
    "./components/**/*.{js,ts,jsx,tsx}",
​
    // Or if using `src` directory:
    "./src/**/*.{js,ts,jsx,tsx}",
  ],
  theme: {
    extend: {},
  },
  plugins: [],
}

postcss.config.js

module.exports = {
  plugins: {
    tailwindcss: {},autoprefixer: {},
  },
}

package.json

{
  "name": "todo",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "@next/font": "13.1.3",
    "eslint": "8.32.0",
    "eslint-config-next": "13.1.3",
    "next": "13.1.3",
    "react": "18.2.0",
    "react-dom": "18.2.0"
  },
  "devDependencies": {
    "autoprefixer": "^10.4.13",
    "postcss": "^8.4.21",
    "tailwindcss": "^3.2.4"
  }
}

globals.css

@tailwind base;
@tailwind components;
@tailwind utilities;
1
  • your code seems correct. try different versions maybe one of the related packages causing bug: "postcss": "^8.4.13", "tailwindcss": "^3.0.24", "autoprefixer": "^10.4.5", Commented Jan 21, 2023 at 16:34

1 Answer 1

4

Please try after removing line number 6 (blank line) from tailwind.config.js and do npm run dev again. must be some special character at line 6.

Sign up to request clarification or add additional context in comments.

1 Comment

OMG... I completely overlooked that, yes that was the issue! thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.