9

1

Error: dlopen(/Users//Documents/Work/Repo/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node, 0x0001): tried: '/Users//Documents/Work/Repo/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node' (mach-o file, but is an incompatible architecture (have (arm64), need (x86_64)))
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1144:18)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:14)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:92:18)
at Object.<anonymous> (/Users/Documents/Work/node_modules/bcrypt/bcrypt.js:6:16)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Object.require.extensions.<computed> [as .js] (/Users//Documents/Work/Repo///node_modules/ts-node/src/index.ts:431:14)

any idea how to resolve this issue, new here. please let me know any additional info needed here.

vimuth
  • 5,064
  • 33
  • 79
  • 116

4 Answers4

5

I encountered a similar error and what worked for me was upgrading my node version to a higher one. I was getting the error on node version v14.16.1 but then upgraded to v16.16.0 and the issue disappeared. Also, If you are using Mac M1, maybe make sure that you are using rosetta.

2

Seems like you cannot use bcrypt on M1 macs yet instead you will have to use bcryptjs.

As mentioned by @Dmitry Bochok here

You can read more about the differences between bcrypt and bcryptjs How do Node's bcrypt and bcryptjs libraries differ?

Replacing bcrypt with bcryptjs worked for me on MBA M1.

Risky Boy
  • 99
  • 1
  • 5
1

In my case what worked was actually to use an older version of Node by using NVM. That way I could use Node v14 instead of Node v16 that I had installed. It kind of makes sense as it was an app that I created some time ago and probably used Node v14 back then. Nvm is really useful to switch between Node versions.

0

Hi I had the same issue in my M1 Mac; if changing the node version does not help(it did not help me), check your package.json file. Make use that you have "^" before your bycrypt dependency.

Nitin
  • 71
  • 1
  • 6