I'm trying to use a package, brypt, I've installed in project using npm install bcrypt.
I can see the package in node_modules folder but when attempt to import in my code I receive error: "Cannot find module 'bcryptjs' or its corresponding type declarations."
I've tried amending the moduleResolution value in tsconfig.json as thought this may be my issue but still a problem. Can anyone see/guide me, as to what I am doing wrong here?
This is content of my tsconfig.json file:
{
"compilerOptions": {
"target": "ESNext",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": [
"./*"
]
}
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts"
],
"exclude": [
"node_modules"
]
}
and this is where I'm trying to use method:
import { IUserAuthenticatedResponse } from "@/types/userAccountTypes";
import axios from "axios";
import bcrypt from 'bcryptjs';
export const dynamic = 'force-dynamic' // defaults to auto
export async function POST(request: Request) {
const body = await request.json();
const { emailAddress, password } = body;
async function authenticateUser(cancel = false): Promise<IUserAuthenticatedResponse[]> {
const salt = bcrypt.genSaltSync(10)
const response = await api.request({
url: process.env.apiBaseUrl + 'authenticateUserAccount/' + emailAddress + "/" + password,
method: "GET",
// retrieving the signal value by using the property name
signal: cancel ? cancelApiObject[this.get.name].handleRequestCancellation().signal : undefined,
})
return response.data
}
}
Thanks for any assitance you can offer.
Not sure why but seems I had to install using following: