I am trying to upgrade Nylas from v2 to v3 in my already existing React-Javascript repository. Currently I am trying to implement the Nylas Scheduler Editor. I am following the react sample provided in Github.
As shown in the sample project, I am importing { NylasSessions } from @nylas/identity package.
I am using the latest version of the package.
But I am getting this error while running the application:
Attempted import error: ‘@nylas/identity’ does not contain a default export (imported as ‘NylasSessions’)
i have tried with that as well. that’s what i had started with as per the github samples. still no luck. same error. i was just playing around with the import statement.
@koustav I just tried it out and it works fine for me I’m not by any means a Node developer…so I just download the source code, run npm install and then npm run dev…all good for me…
hello @Blag, the source code works fine for me as well but fails when I am using the same code in my React-Javascript repository. Here are some details that might help:
Versions:
“@nylas/identity”: “latest”,
“@nylas/login-component”: “latest”,
“@nylas/react”: “latest”,
“react”: “^18.3.1”,
node: v18.20.4
I am not using Vite and my React repository is in Javascript but the Nylas sample code is in Typescript and using Vite.
My import statement:
import { NylasSessions } from ‘@nylas/identity’;
hello @Blag, I have created a small Github repo with the piece of code that is causing issue. Here is the link: GitHub - KoustavFrost/nylas-schedule-editor
I have also mentioned the steps to replicate the error in the README file.
thanks.
I took a look at the repo, and was able to reproduce the error.
The issue with the `@nylas/identity` package is that its **ESM build**
is missing required file extensions in its internal
imports (e.g., import './app'; instead of import './app.js';).
Modern bundlers default to using the ESM version,
which leads to module resolution errors.**Workaround:**
To avoid these errors, change your import to use the pre-built,
bundled version from the dist folder:
import { NylasSessions } from '@nylas/identity/dist/nylas-identity.es.js';
This file is fully bundled and avoids the ESM issues.
Why it works in the github sample?
The sample code uses Vite as a bundler.
Vite is known for being ESM-first, meaning it works well
with ESM dependencies out-of-the-box, even in strict module
environments. This is likely why it can resolve the missing
extensions or imports in `@nylas/identity` without errors.