Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I have nodejs version 10.19.0, ubuntu 20.04.2, and use webstorm ide for javascript. I tried installing both bcrypt and sha256 and neither libraries worked.
For example, after installing bcrypt the first 2 lines in my javascript code is:
const bcrypt = require('bcrypt');
alert('hello');
The alert function only pops up when I comment out the first line. I have the same problem with sha256.
I have tried installing, uninstalling, and reinstalling bcrypt and bcryptjs (even the bcrypt version that was supposed to match my node version). Why can't I seem to get these libraries to install properly? Thanks.
PS. I tried 'npm install bcrypt'
$ npm list -g
(node:40710) ExperimentalWarning: The fs.promises API is
experimental
/home/philip/.nvm/versions/node/v10.16.3/lib
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]
–
–
–
First of all you should properly look into how to install bcrypt in your project, You can look into this link https://www.npmjs.com/package/bcrypt for detailed installation and you would also be able to get further help from it. But right now the problem is that you are not importing bcrypt properly in your js file. You should import it like this and it will work fine.
const bcrypt = require('bcryptjs')
–
–
–
–
–
https://browserify.org/ is the only solution I tried that worked. Thank you everyone for your help.
Edit: I no longer need to use browserify to use bcrypt in my javascript application!
Here are the changes I did to make it work:
In todoApp.html...
<link rel="stylesheet" type="text/css" href="css/todo.css">
<meta charset="UTF-8">
<title>Todo App</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/bcrypt.js"></script>
</head>
<script src="scripts/todo.js"></script>
</body>
In todo.js
let bcrypt = dcodeIO.bcrypt;
const saltRounds = 12;
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.