Next.js Discord

Discord Forum

Is there a way to prevent the import of a package when in local dev?

Unanswered
Spectacled bear posted this in #help-forum
Open in Discord
Avatar
Spectacled bearOP
I am using openpanel for analytics but it seems with next 15, it breaks when importing the package in dev server when using turbo. I don't need it in dev env so I was wondering if there was a way to disable the import while running in dev server?

1 Reply

Avatar
Miniature Pinscher
let myModule;

if (process.env.NODE_ENV === "producion") {
  myModule = await import("module-used-in-production");
}