TS7016: Could not find a declaration file for module 'faker/locale/en_CA'


I'm getting this error:


TS7016: Could not find a declaration file for module 'faker/locale/en_CA'. '.../myproject/node_modules/faker/locale/en_CA.js' implicitly has an 'any' type.


With this code:

import * as faker from 'faker/locale/en_CA';

The thing is, I installed @types/faker, and I can see that node_modules/@types/faker/index.d.ts does in fact include:

declare module "faker/locale/en_CA" { export = fakerStatic; }

So the module <em>has</em> been declared, but TS can't find it for some reason.

Here's my tsconfig:

{ "compilerOptions": { "strict": true, "importHelpers": false, "inlineSources": true, "noEmitOnError": true, "pretty": true, "module": "commonjs", "noImplicitAny": true, "suppressImplicitAnyIndexErrors": true, "removeComments": true, "preserveConstEnums": false, "sourceMap": true, "lib": ["es2017","esnext.asynciterable"], "skipLibCheck": true, "outDir": "dist", "target": "es2018", "declaration": true, "types" : ["node"], "resolveJsonModule": true, "esModuleInterop": false, "baseUrl": ".", "paths": { "*": ["types/*"] } }, "files": [ "src/main" ], "exclude": [ "node_modules" ] }

Am I missing something?

<hr />

Note that

import * as faker from 'faker';

Works perfectly fine.

Both VSCode and PhpStorm can find 'faker/locale/en_CA' no problemo, it's just tsc that can't.


Try removing "types" : ["node"] from tsconfig.json. According to <a href="https://www.typescriptlang.org/docs/handbook/tsconfig-json.html#types-typeroots-and-types" rel="nofollow">the documentation</a>, that line is saying you don't want TypeScript to load types for any package other than node.


  • @types/googlemaps/index.d.ts' is not a module
  • Combine mocha, Typescript (and watch)
  • RxJs-5-to-6-migrate crashes
  • Visual Studio 2017 Javascript How to set 'experimentaldecorators'
  • How to debug 'value of ESP was not saved across function call' error?
  • How to store result of stored procedure in a variable using SQL Server
  • Get row for each user where the count of a value in a column is maximum
  • event not defined in Firefox
  • sql if statement checking for null parameter
  • Convert from hex-encoded CLOB to BLOB in Oracle
  • Conversion failed when converting the nvarchar value 'SELECT * FROM
  • Extend Name Box
  • Angular2 & SystemJS : Cannot find module while building a moduleLoader
  • Instanciate service on startup in Angular2
  • Receive custom intent without activity restart
  • Select from table that does not exist
  • iOS - Is this a task for enums?
  • get passwords from chrome
  • NHibernate proxyexception
  • How can I emulate a recursive type definition in C++?
  • mapping between two ontologies
  • Can't compile Arduino CapSense example
  • What does the TypeScript “lib” option really do?
  • can variables be set randomly when declaring them again?
  • Need code translation from VB to C#
  • Best practice to eliminate magic numbers within a member function
  • php script is parsing content from RTE (tt_news) but internal links are not appearing as speaking ur
  • CERN ROOT exporting data to plain text
  • Trying to get the char code of ENTER key
  • Using Sax parsing to edit and write XML in VB6
  • Eliminate partial duplicate rows from result set
  • Debug.DrawLine not showing in the GameView
  • Yii2: Config params vs. const/define
  • What is the “return” in scheme?
  • Buffer size for converting unsigned long to string
  • Hits per day in Google Big Query
  • What are the advantages and disadvantages of reading an entire file into a single String as opposed
  • How to get Windows thread pool to call class member function?
  • How to get NHibernate ISession to cache entity not retrieved by primary key
  • Observable and ngFor in Angular 2