5

i'm using nextjs with typescript and tailwindcss. I want to move styles folder to src folder, i already added baseUrl with value src options in my tsconfig.json file, but I got an error like this :

    ./node_modules/next/dist/compiled/css-loader/cjs.js??ruleSet[1].rules[2].oneOf[5].use[1]!./node_modules/next/dist/compiled/postcss-loader/cjs.js??ruleSet[1].rules[2].oneOf[5].use[2]!./node_modules/tailwindcss/tailwind.css
TypeError: Object.fromEntries is not a function

and how i move styles folder to src folder, i want to make my folder structure simpler. thank you

Sandhi
  • 89
  • 2
  • 11
  • Does this answer your question: [Object.fromEntries is not a function error when using chakra-ui and next.js](https://stackoverflow.com/questions/67550901/object-fromentries-is-not-a-function-error-when-using-chakra-ui-and-next-js)? `Object.fromEntries()` is only supported from Node.js v12 onwards. – juliomalves Jan 20 '22 at 10:46

3 Answers3

27

Delete the .next folder, then run the dev server again (with npm run dev).

This worked in my case. I'm guessing it's some kind of caching issue. Obviously you'll need to change your tailwind.config.js where the content should check ./src/**/*.{js,jsx,ts,tsx} rather than ./pages/**/*.{js,jsx,ts,tsx}.

Grant Pitt
  • 471
  • 5
  • 10
3

I had the same problem after moving my files under src to clean up my root directory. I copied the config options for tailwind.config.js from this example repo from Tailwind Labs and found that it worked for me.

module.exports = {
  purge: {
    content: ['./src/**/*.{js,jsx,ts,tsx}', './next.config.js'],
  },
  ...
  • This fixed for me in a 2023 Next js boiler plate, typescript, moving everything inside a `src` folder to make things easier, tailwindcss broke, this fixed, ty – Rolando Niubó Feb 03 '23 at 02:13
  • This worked for me but I also get a warning: "The `purge`/`content` options have changed in Tailwind CSS v3.0. With this upgrade guide: https://tailwindcss.com/docs/upgrade-guide#configure-content-sources – Robin Dalmy Mar 15 '23 at 14:32
0

config files must be stored in main root like next.config.js . but style files can be stored in src directory. read this doc: https://tailwindcss.com/docs/guides/nextjs

Alireza Amini
  • 1,180
  • 6
  • 7
  • I already do, I keep the file as it, but still got an error. I fixed the error by delete node_modules and reinstall it. thanks for the answer :) – Sandhi Jul 16 '21 at 09:31