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

509
Vistas
Unable to set up the new Faker library

I am trying to set up the new @faker-js/faker library. So far, I did this:

npm i @faker-js/faker -D

Added faker.d.ts at the top level. So the tree is like this:

enter image description here

faker.d.ts contents is this:

// faker.d.ts
declare module '@faker-js/faker' {
  import faker from 'faker';
  export default faker;
}

I am trying to use the mock like this:

import faker from 'faker';

import { ParameterMessage } from 'packages/ts/container/Parameter';

export const Parameter: ParameterMessage = { id: faker.dataType.uuid };

But am keep getting an error, saying

Cannot find module 'faker' or its corresponding type declarations.ts(2307)

Unable to resolve path to module 'faker'.

I am also getting this in faker.d.ts

File '/home/aironside@ant.local/Documents/microfrontends/telegram-manager/src/faker.d.ts' is not a module.

When hovering over 'faker' in import faker from 'faker';

What am I missing?

Here is a reproduced sandbox

over 4 years ago · Santiago Trujillo
4 Respuestas
Responde la pregunta

0

Try to install the corresponding type declarations by running the command npm i @types/faker

over 4 years ago · Santiago Trujillo Denunciar

0

What worked for me so far is to have a faker.d.ts file in the root (where package.json is). The single entry in that file is declare module "@faker-js/faker";

over 4 years ago · Santiago Trujillo Denunciar

0

Please check this example https://codesandbox.io/s/modest-dream-5cyq7?file=/src/App.tsx, the problem with the old faker types are that some type is missing, like the animal function.

If its possible for you please use the new released v6 of the fakerjs

over 4 years ago · Santiago Trujillo Denunciar

0

I created a sample project: https://stackblitz.com/edit/faker-js-demo-b16k2u?file=index.ts
I may link it into our README.md if needed (I'm one of the maintainers of @faker-js/faker 🙂)

over 4 years ago · Santiago Trujillo 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