Ivan
Ivan

Reputation: 125

Module '"faker"' can only be default-imported using the 'allowSyntheticDefaultImports' flag error after using npm i faker

I am new in Angular. I installed faker by using the command npm i faker. Now I get the message

Module '"faker"' can only be default-imported using the 'allowSyntheticDefaultImports' flagts(1259)
index.d.ts(395, 5): This module is declared with using 'export =', and can only be used with a default import when using the 'allowSyntheticDefaultImports' flag

The app structure is node_modules faker index.js

In index.js I have

// since we are requiring the top level of faker, load all locales by default
var Faker = require('./lib');
var faker = new Faker({ locales: require('./lib/locales') });
module['exports'] = faker;

I would really appreciate any suggestion or answer

Upvotes: 2

Views: 2175

Answers (1)

Troom
Troom

Reputation: 571

Just use:

import * as faker from "faker";

Reference

Upvotes: 3

Related Questions