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

Module parse failed: Unexpected character '�' (1:2) You may need an appropriate loader to handle this file type #365

Closed
urbno opened this issue Nov 24, 2022 · 4 comments

Comments

@urbno
Copy link

urbno commented Nov 24, 2022

Hi All,

Steps to reproduce

  1. Create new typescript based project with Next.js
  2. Install the required package npm i argon2
  3. npm run dev

Expected behaviour

I just would like to try this library in my project.

Actual behaviour

I would like to familiarize myself with this library, but I got an error during compiling.

error - ./node_modules/argon2/lib/binding/napi-v3/argon2.node
Module parse failed: Unexpected character '�' (1:2)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)
Could not find files for / in .next/build-manifest.json

Environment

Operating system:
Windows 10 64bit

Node version:

node -v     
v18.12.1

npm -v
9.1.2

Could you please suggest me any solution?

Thanks in advance,
Norbert

@ranisalt
Copy link
Owner

You can not use Argon2 on the client-side, that means you can not use it in React components (i.e. Next.js pages). You should be able to use it in server-side functions, such as getServerSideProps or getStaticProps.

@Voltra
Copy link
Contributor

Voltra commented Dec 8, 2022

Related issue in nuxt-session

I can understand Argon2 not being able to be used on the client-side, however the error occurs during build phases (i.e. when using webpack, rollup, vite, etc...).

I assume the issue is related to the import of the .node file

@Voltra
Copy link
Contributor

Voltra commented Dec 8, 2022

bcrypt seems to be using @mapbox/node-pre-gyp and users switching to bcrypt have reported it fixes their build issues.

Maybe migrating to using that would be a good way to bridge the gap between argon2 and build tools

@ranisalt
Copy link
Owner

ranisalt commented Dec 9, 2022

@Voltra we already use that. For usage in webpack, check #261 (others should follow suit)

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

No branches or pull requests

3 participants