material-tailwind: SyntaxError: Unexpected token 'export'
Hello, I have used old version and it run well until new version come out. I follow instruction to install new version, however I get error:
...\node_modules\@material-tailwind\react\index.js:1
export * from "./components/Accordion";
^^^^^^
SyntaxError: Unexpected token 'export'
at compileFunction (<anonymous>)
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1031:15)
at Module._compile (node:internal/modules/cjs/loader:1065:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.@material-tailwind/react (...\.next\server\pages\_app.js:216:18)
Here is my _app.js code:
import '../styles/globals.css'
import 'tailwindcss/tailwind.css'
import '@material-tailwind/react'
import React from 'react';
import App from 'next/app';
import MainLayout from '../components/mainlayout';
class MyApp extends App {
render() {
const { Component, pageProps } = this.props;
const Layout = Component.Layout || Component.DefaultLayout;
return (
<MainLayout>
<Layout>
<Component {...pageProps} />
</Layout>
</MainLayout>
);
}
}
export default MyApp;
this is tailwind.config.js
const withMT = require("@material-tailwind/react/utils/withMT");
module.exports = withMT({
content: [
'./pages/**/*.{js,ts,jsx,tsx}',
'./components/**/*.{js,ts,jsx,tsx}',
'./src/layouts/**/*.{html,js}',
'./src/index.html',
{ raw: '<div class="font-bold">', extension: 'html' },
],
theme: {
extend: {},
},
plugins: [],
});
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 19
@ichuoi I found the issue it’s because of the ES Modules in next.js you can simply solve this using by the following method:
npm i next-transpile-modules
oryarn add next-transpile-modules
All the best, Sajad
All I needed was to update to 16.17.0, sorry for this……Rich
Same fix worked for me as well. I am following this thread waiting for a more elegant solution.
Hi @ichuoi, @PippoApps, @Yonatani,
I’ve updated the @material-tailwind/react and now you can use it without and third-party library with next.js, remix.js and vite.js.
All the best, Sajad
@sajadevo I have added you to my repo, because it still private, you can check the local-test branch in folder name nextjs_frontend please careful, I’m deploying the master branch on vercel, thanks
Hi @ichuoi
I don’t know why you put the following import
import '@material-tailwind/react'
this is not valid.All the best, Sajad