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

Unexpected identifier 'assert' on imports in Node v22 #873

Open
davideruby opened this issue Jan 21, 2025 · 0 comments
Open

Unexpected identifier 'assert' on imports in Node v22 #873

davideruby opened this issue Jan 21, 2025 · 0 comments

Comments

@davideruby
Copy link

Describe the bug

I ran the tests of the orama package from a devcontainer and unfortunately the dataset.test.ts and insert.test.ts failed with the error:
SyntaxError: Unexpected identifier 'assert'

This happens because the devcontainer uses node:lts-alpine as base image. At the time that I'm writing this issue, the version of node which this image uses is node v22. This version does not support anymore the assert, in favour of the new keyword with.

So, in order to fix this error, I think we can either:

  • replace assert with with, or
  • fix the node version of the devcontainer to node v20, for example using the image node:20-alpine.

In addition, I googled the error and I found this very useful stackoverflow post which I do recommend you to read. In this post there is a very detailed overview of the problem and it is explained how swapping assert with with will fix the problem for node 22 and later, but with the consequence of breaking it for Node 16 and 17.

So, what do you think about it? Let me know and I would be glad to open a pr.

To Reproduce

  1. Open the orama repository in a devcontainer. Make sure you are using the latest node:lts-alpine image (check that the node version is v22 from a shell inside the container with node -v).
  2. Run the tests of the orama package.

Expected behavior

I expect the tests to succeed.

Environment Info

Infos of the devcontainer:
- OS: Alpine Linux v3.21
- Node: 22.13.0
- Orama: 3.0.5

Affected areas

Environment/OS

Additional context

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant