简体   繁体   中英

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

Just use:

import * as faker from "faker";

Reference

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM