Next.js Discord

Discord Forum

Critical dependency: the request of a dependency is an expression

Unanswered
"use php" posted this in #help-forum
Open in Discord
So I installed the npm package dynamoose.

And when I tried to use it, I get this error, and the server exists.

I also noticed this issue: https://github.com/dynamoose/dynamoose/issues/1617

However, I also added to next config, but it didn't work:
// @ts-check
import { setupDevPlatform } from '@cloudflare/next-on-pages/next-dev';

// Here we use the @cloudflare/next-on-pages next-dev module to allow us to use bindings during local development
// (when running the application with `next dev`), for more information see:
// https://github.com/cloudflare/next-on-pages/blob/5712c57ea7/internal-packages/next-dev/README.md
if (process.env.NODE_ENV === 'development') {
  await setupDevPlatform();
}

/** @type {import('next').NextConfig} */
const nextConfig = {

  experimental: {
    serverComponentsExternalPackages: ['dynamoose']
  }
};

export default nextConfig;

2 Replies

I'm on v14.1.0
Now keeping this error on side, If that package is using dynamic import, will it affect performance or anything? As As far as I know, webpack won't know what packages to include in prod build