Next.js Discord

Discord Forum

Sequelize with postgress but nextjs need Mariadb modul

Unanswered
Huyenlong posted this in #help-forum
Open in Discord
Hi

I use sequelize and postgress database, but when i build i have this error :

⨯ ./node_modules/@sequelize/core/lib/sequelize.internals.js:30:1
Module not found: Can't resolve '@sequelize/mariadb'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./node_modules/@sequelize/core/lib/sequelize-typescript.js
./node_modules/@sequelize/core/lib/sequelize.js
./node_modules/@sequelize/core/lib/index.js
./node_modules/@sequelize/core/lib/index.mjs
./server/models/Federation.ts
./src/app/api/route.ts
 GET /_next/static/webpack/8734a8b93890bdb9.webpack.hot-update.json 500 in 576ms
 ⚠ Fast Refresh had to perform a full reload due to a runtime error.
 GET /api 500 in 29ms

* I use app/api/route
* i configure atabase credentials in server/models/index.tsx
I do not know why nextjs need maria db

Sorry for my English

3 Replies

i also do this :
const nextConfig = {
    webpack: (config, { isServer }) => {
      if (!isServer) {
        config.resolve.fallback = {
          mariadb: false,
          ['@sequelize/mariadb']:false
        };
      }
  
      return config;
    },
  }; 

still not works
Hi

i follow this :

and do this :
https://github.com/vercel/next.js/discussions/49432
      config.ignoreWarnings = [
        { module: /node_modules\/node-fetch\/lib\/index\.js/ },
        { file: /node_modules\/node-fetch\/lib\/index\.js/ },
      ];

still not works
Hi

i just find a source part of problem.

Maybe i use in the bad way
  const sequelize = new Sequelize({ dialect: PostgresDialect });


Because when i do this , in a controller :
export const POST = async (req: Request, res: NextApiResponse) => {
  const data = await req.json();

// if i comment, this it's work
  const sequelize = new Sequelize({ dialect: PostgresDialect });
  // await sequelize.authenticate();

  console.log("authenticate");

  // const federation = await Federation.create({ name })
  return NextResponse.json("federation")
}


Someone know what i did bad ?