Skip to content
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

Update package.json #1504

Merged
merged 2 commits into from
Aug 2, 2024
Merged

Update package.json #1504

merged 2 commits into from
Aug 2, 2024

Conversation

Fohlen
Copy link
Contributor

@Fohlen Fohlen commented Jun 26, 2024

Fixes issue in Node 22 of Hanko not being a valid module

Description

In Node 22 the following error is generated when installing Hanko Elements:

(node:30657) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)

You can try this out by:

  • using Node 22 (e.g brew install node@22)
  • using SvelteKit (e.g npm create svelte@latest mytest)
  • installing Hanko (npm install --save @teamhanko/hanko-elements)
  • running the dev server (npm run dev)

This is caused by the fact that HankoElements is not declared as an ESM module correctly. As Node.js is migrating away from CommonJS, this is a rather known bug in many packages. To fix this issue, you have two options:

  • declare the module type
  • use .mjs which will instruct Node.js to import files using ESM

The later however isn't really supported by browsers.

Tests

Updating the package.json of an installed Hanko Elements with the proposed diff "just works" and unbreaks builds.

Additional context

I attached a vite_build.log log for reference.

Fixes issue in Node 22 of Hanko not being a valid module
@lfleischmann lfleischmann merged commit 2ac511f into teamhanko:main Aug 2, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants