vscode-javascript-repl-docs
vscode-javascript-repl-docs copied to clipboard
[BUG] - Bcrypt not running properly
[PROBLEM]
Running javascript repl doesn't identify bcrypt functions properly
[HOW TO REPRODUCE]
import * as bcrypt from 'bcrypt';
class Teste {
async main() {
const passwords = [
'anicepassword',
'anicepassword2'
]
for(const password of passwords) {
const salt = await bcrypt.genSalt(12);
let hash = await bcrypt.hash(password, salt);
console.log(`password = ${password} - hash=${hash}`);
console.log(await bcrypt.compare(password, hash))
}
}
}
new Teste().main();
[image result]
npx ts-node test.bcrypt.ts
Someone is facing the same issues or something like that?
More information about my workspace:
WSL 2 - ubuntu 20 bcrypt 5 node v14.15.4
Feel free to ask something else.
Hi @brunocasado thank you so much for your feedback and all the information that you have attached about it.
Basically, the repl is using by default a runtime context that is created on the same process.
This is "lighter" compared to use a separate process but it has issues sometimes for example when users are running-testing code through repl specifically for node.js
or they include some node modules that have support only for node.js' runtime.
So in order to support all these cases, it has been added the "JavaScript-repl: Context" option in vscode preferences-settings. So you can use 'Node' instead of the default 'VM'.
I have tested your example by using the Node
option and it works properly (please reload the vscode's window, in order to be sure that the new option has been applied).
Thanks again for your feedback and feel free to post again if you have any issues or questions.