Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bcrypt crashing node_modules

I'm currently building a react native app using typescript and when after running npm i bcrypt node_modules crash and says the error below:

ERROR in ./node_modules/@mapbox/node-pre-gyp/lib/util/nw-pre-gyp/index.html 1:0 Module parse failed: Unexpected token (1:0) 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 <!doctype html> | <html> | <head>

I tried removing bcrypt and installing it back, but still getting that issue. I also tried remove bcrypt from package.json, removed node_modules and then re-installed node, and works, but when install bcrypt back, it gives the same error.

Any idea?

like image 781
Gabriel Donada Avatar asked Mar 22 '26 00:03

Gabriel Donada


2 Answers

After hours breaking my head on it, I tried using npm i --save-dev @types/bcryptjs instead and then worked.

The import can be used like this: import bcrypt from 'bcryptjs'

like image 164
Gabriel Donada Avatar answered Mar 23 '26 19:03

Gabriel Donada


I faced a similar issue and successfully resolved it with the following steps:

If you have the existing bcrypt package installed, remove it:

npm rm bcrypt @types/bcrypt

Install bcryptjs as a development dependency:

npm i bcryptjs

Additionally, install the type definitions for bcryptjs:

npm i --save-dev @types/bcryptjs

Following these steps resolved the issue for me.

Hopefully, it helps you too!

like image 37
Leon Shabani Avatar answered Mar 23 '26 19:03

Leon Shabani



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!