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?
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'
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With