I am currently using NuxtJS and bcrypt to hash my passwords for a project that I am working on. However, when importing bcrypt into a .vue file and using a funciton it just crashes and shows this error:
500 global is not defined
at node_modules/.pnpm/buffer@4.9.2/node_modules/buffer/index.js (http://127.0.0.1:3000/_nuxt/node_modules/.cache/vite/client/deps/bcrypt.js?v=dfc7ac6d:10881:35)
at __require2 (http://127.0.0.1:3000/_nuxt/node_modules/.cache/vite/client/deps/chunk-6NOISVLF.js?v=351e0e6d:16:50)
at node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/_stream_readable.js (http://127.0.0.1:3000/_nuxt/node_modules/.cache/vite/client/deps/bcrypt.js?v=dfc7ac6d:304119:19)
at __require2 (http://127.0.0.1:3000/_nuxt/node_modules/.cache/vite/client/deps/chunk-6NOISVLF.js?v=351e0e6d:16:50)
at node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/readable-browser.js (http://127.0.0.1:3000/_nuxt/node_modules/.cache/vite/client/deps/bcrypt.js?v=dfc7ac6d:305131:34)
at __require2 (http://127.0.0.1:3000/_nuxt/node_modules/.cache/vite/client/deps/chunk-6NOISVLF.js?v=351e0e6d:16:50)
at node_modules/.pnpm/are-we-there-yet@2.0.0/node_modules/are-we-there-yet/lib/tracker-stream.js (http://127.0.0.1:3000/_nuxt/node_modules/.cache/vite/client/deps/bcrypt.js?v=dfc7ac6d:305209:18)
at __require2 (http://127.0.0.1:3000/_nuxt/node_modules/.cache/vite/client/deps/chunk-6NOISVLF.js?v=351e0e6d:16:50)
at node_modules/.pnpm/are-we-there-yet@2.0.0/node_modules/are-we-there-yet/lib/tracker-group.js (http://127.0.0.1:3000/_nuxt/node_modules/.cache/vite/client/deps/bcrypt.js?v=dfc7ac6d:305245:25)
at __require2 (http://127.0.0.1:3000/_nuxt/node_modules/.cache/vite/client/deps/chunk-6NOISVLF.js?v=351e0e6d:16:50)
bcrypt and native nodejs modules in general don't play well with bundling. Consult your bundler documentation to mark bcrypt as an external dependency which should not be bundled.
I am currently using
NuxtJS
andbcrypt
to hash my passwords for a project that I am working on. However, when importing bcrypt into a.vue
file and using a funciton it just crashes and shows this error:Versions
8.7.1
v20.1.0
v22H2