bun icon indicating copy to clipboard operation
bun copied to clipboard

bcrypt does not work

Open zdnk opened this issue 2 years ago • 4 comments

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

zdnk avatar Jul 06 '22 20:07 zdnk

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.

shanecaf avatar Jul 07 '22 00:07 shanecaf

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":{}} }

Nick-Mazuk avatar Aug 14 '22 20:08 Nick-Mazuk

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.

chrisdavies avatar Jan 09 '23 17:01 chrisdavies

Same issue once I ran bun install but, tried npm install and it solved the issue. No idea why.

Tony308 avatar Feb 15 '23 00:02 Tony308

+1

bmeeder22 avatar Sep 19 '23 19:09 bmeeder22

Same issue

phantuanngoc68 avatar Oct 07 '23 14:10 phantuanngoc68