I have import the package : const uuidv1 = require("uuid/v1"); and used in virtual field: userSchema.virtual('password') .set(function (password) { this.password = password this.salt = uuidv1() this.hashed_password = this.encryptPassword(password) }) .get(function () { return this._password }) But I have got the error: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './v1' is not defined by "exports"
const uuidv1 = require("uuid/v1");
userSchema.virtual('password') .set(function (password) { this.password = password this.salt = uuidv1() this.hashed_password = this.encryptPassword(password) }) .get(function () { return this._password })
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './v1' is not defined by "exports"
Is there any other method to import the packages?
ECMAScript Module syntax:
import { v4 as uuidv4 } from 'uuid'; uuidv4(); // ⇨ '9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d'
CommonJS syntax:
const { v4: uuidv4 } = require('uuid'); uuidv4(); // ⇨ '1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed'