【发布时间】:2022-01-14 21:23:44
【问题描述】:
当我在 localhost 端口上加载我的网站时,会产生以下错误。我使用 bcrypt 对密码和用户名进行哈希处理。
Uncaught TypeError: Failed to resolve module specifier "bcryptjs". Relative references must start with either "/", "./", or "../".
下面是我的 index.js:
import bcrypt from 'bcryptjs';
const saltRounds = 10;
const PlainTextUser = document.querySelector("body > div > form > div:nth-child(1) > input[type=text]");
const PlainTextPassword = document.querySelector("body > div > form > div:nth-child(2) > input[type=password]");
var hashedPW = bcrypt.hashSync('test', saltRounds);
var hashedUser = bcrypt.hashSync('test', saltRounds)
console.log(hashedPW + " " + hashedUser)
【问题讨论】:
-
为什么要找到
bcryptjs?您是否安装了名为bcryptjs的模块?你是怎么安装的?它是否出现在你的 package.json 中? -
我已经安装了 brcypt,它确实出现在 package.json 中
-
bcrypt和bcryptjs是不同的名称。您必须使用您安装的东西,而不是使用其他名称的东西。
标签: javascript node.js bcrypt