-
Notifications
You must be signed in to change notification settings - Fork 704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESM Compatibility Issue with nanoid in Internal Dependency #256
Comments
@DSamuelHodge thank you for this detailed bug report. I double checked and I'm unable to reproduce this issue with a fresh Next project (created via Can you please list
Also, please feel free to book a support session with me here, it might be easier to get to the bottom of this 'live' vs asynchronously |
Which package manager you are using (and which version), i.e. npm, yarn, etc.? How you created the next app? (e.g. create-next-app) Which OS you are on? are you seeing this with an existing project, or a fresh project? Anything that might be unique on your setup. I will also book a support session. Thanks in advance. |
This issue was not able to be duplicated, seemed to be resolved when I had uninstalled and re-installed CopilotKit. Note: The TailwindCSS v4 isn't just a plugin anymore, the latest update implements a Unified toolchain Built-in @import handling — no need to setup and configure a tool like postcss-import. |
I'm facing the same issue in a Next app inside a NX monorepo. |
Same issue on my nextjs web app
|
same here |
My workaround export const CopilotKit = dynamic(
() => import('@copilotkit/react-core').then((w) => w.CopilotKit),
{
ssr: false
}
);
export const CopilotSidebar = dynamic(
() => import('@copilotkit/react-ui').then((w) => w.CopilotSidebar),
{
ssr: false
}
); Instead of import { CopilotKit } from '@copilotkit/react-core';
import { CopilotSidebar } from '@copilotkit/react-ui'; And add the packages into next.config.js
|
This should be fixed in the latest version:
Please let me know if you still experience issues related to ESM compatibility |
I'm encountering an ESM compatibility issue when integrating CopilotKit into my Next.js project. The root cause seems to be the use of require('nanoid') within CopilotKit's internal dependencies. This conflicts with the ESM import system used in modern Next.js setups.
Error Details:
Error Message: "Module not found: ESM packages (nanoid) need to be imported. Use 'import' to reference the package instead. https://nextjs.org/docs/messages/import-esm-externals"
Call Trace: (Include the import trace you provided)
Steps to Reproduce:
Create a standard Next.js project.
Install the latest version of CopilotKit (@copilotkit/react-core, etc.)
Attempt to use a CopilotKit component within the Next.js application.
Conflicting
nanoid --versions
north@0.1.0 /Users/argosmacdevelopmentsystem/north
├─┬ @copilotkit/react-core@0.20.1
│ └── nanoid@4.0.2
├─┬ @copilotkit/react-textarea@0.30.1
│ └── nanoid@4.0.2
├─┬ @copilotkit/react-ui@0.17.1
│ └── nanoid@4.0.2
├── nanoid@5.0.6
├─┬ next@14.1.2
│ └─┬ postcss@8.4.31
│ └── nanoid@3.3.7
└─┬ postcss@8.4.35
Workarounds:
I've temporarily enabled experimental.esmExternals: 'loose' in my Next.js config, but I understand this isn't optimal for performance and long-term use. (Quit working).
Proposed Solution:
Updating the internal dependency that uses require('nanoid') to utilize ESM-style imports instead (import { nanoid } from 'nanoid') would align CopilotKit better with modern JavaScript /Typescript practices.
I greatly appreciate the CopilotKit project. Thank you for considering this issue and working towards improved compatibility!
The text was updated successfully, but these errors were encountered: