bun
bun copied to clipboard
bcrypt does not work
Hello,
getting this issue:
Error: Cannot find module '
/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node' Require stack:
/node_modules/bcrypt/bcrypt.js /dist/users/users.service.js /dist/users/users.module.js /dist/app.module.js /dist/main.js at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15) at Function.Module._load (node:internal/modules/cjs/loader:778:27) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object. ( /node_modules/bcrypt/bcrypt.js:6:16) at Module._compile (node:internal/modules/cjs/loader:1105:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) Script error "start" exited with 1 status
This is happening to me as well, but this only seems to be happening when using bun add
, while if you use npm
it works completely fine.
Getting a similar error with other dependencies as well, even those installed with npm.
It seems like many npm depdendencies use var Module = require("module");
, and there's only two properties currently supported for it.
const Module = require("module");
console.log({ Module })
// { Module: {"builtinModules":["node:path","node:fs","bun:ffi","bun:sqlite"],"default":{}} }
For anyone stumbling across this, I was able to get the @node-rs/bcrypt
package to work, so that's a possible workaround depending on the functionality you need.
Same issue once I ran bun install
but, tried npm install
and it solved the issue. No idea why.
+1
Same issue