'How to install the tailwind elements in nextjs?

I am installing the tailwind elements for the slider in nextjs, but it is not working in the nextjs there is any solution to install it in an easy way.

[I follow this method][1] [1]: https://tailwind-elements.com/quick-start/ When I adding this import 'tw-elements'; Then it show me an error



Solution 1:[1]

I faced the same problem and the fix is quite simple. In your project go and edit node_modules/tw-elements/dist/js/index.min.js

At the very beginning change

function(n){

for this

function(n){if (typeof window == "undefined")return;

Voila!!

NOTE: If you are using VErcel or any other Nextjs hosting for your project you will notice that it automatically download all modules, so the changes you made in your local project are not reflected in the deployment.

Fortunately you can run a pre-build command in Vercel:

  1. Go to Project settings_>General

  2. Override the Build command

  3. Put this in the field:

    sed -i 's/function(n){var r={};function o(t)/function(n){if(typeof window == "undefined")return;var r={};function o(t)/g' node_modules/tw-elements/dist/js/index.min.js; next build

Well... it's crappy and ugly but it works

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1