Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

204
Vistas
I'm getting undefined packages even though I have them in my package.json and node_modules folder

So I'm developing a web app using NestJS as its backend. Also I'm using docker to build all my backend. I'm having a problem that some installed packages logs as "undefined" and some other works properly.

For example in my CreateUser class I have

import bcrypt from 'bcrypt';

@Injectable()
export class CreateUser {
  constructor(
    @InjectRepository(User)
    private usersRepo: Repository<User>,
  ) {}

  async execute(input: CreateUserInput): Promise<User> {
    console.log('bcrypt', bcrypt);
    const user = this.usersRepo.create(input);
    user.email = input.email.trim().toLowerCase();
    user.password = await bcrypt.hash(input.password, 10);
    const newUser = await this.usersRepo.save(user);
    return newUser;
  }

When I execute this function it logs this

bcrypt undefined
data TypeError: Cannot read property 'hash' of undefined

But if I go to my node_modules I have the bcrypt module installed. And the same happens in my package.json

I think its a docker problem but I've gone into the container and inspected the node_modules folder and it also is installed in there. Here goes my docker file just in case

FROM node:12-alpine

ENV NODE_ENV development

RUN mkdir -p /usr/src/app

WORKDIR /usr/src/app

COPY package.json package-lock.json /usr/src/app/

RUN npm install

COPY . .

ENTRYPOINT ["npm", "run", "start:dev"]

Any ideas of why im not being able to use this package?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

you should do like this

import {hash} from 'bcrypt'

and then

 user.password = await hash(input.password, 10);

to understand more please refer to :https://learnjsx.com/category/2/posts/es6-javaScript

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda