0

After I did npm install node-gmail-api, my code cannot find the model. It said "Could not find a declaration file for module 'node-gmail-api'. '/Users/xuanren/Desktop/test/node_modules/node-gmail-api/index.js' implicitly has an 'any' type. Try npm install @types/node-gmail-api if it exists or add a new declaration (.d.ts) file containing declare module 'node-gmail-api'; [7016]"

I checked my node_modules folder, node-gmail-api is there. How do i install node-gmail-api properly?

leopal
  • 4,711
  • 1
  • 25
  • 35
Xuan Ren
  • 11
  • 1
  • 5

1 Answers1

0

Based from this link, try to install its from @types: npm install -D @types/module-name.

Or, if install error, try rewrite import to require:

// import * as yourModuleName from 'module-name';
const yourModuleName = require('module-name');

Also, if you're importing a third-party module example 'foo' that doesn't provide any typings, either in the library itself, or in the @types/foo package, then you can make this error go away by declaring the module in a .d.ts file:

// foo.d.ts
declare module 'foo';

Then when you import foo it'll just be typed as any.

abielita
  • 13,147
  • 2
  • 17
  • 59
  • emmmm it is not working. this is what i got from terminal "code E404 npm ERR! 404 Not Found: @types/node-gmail-api@latest" – Xuan Ren Dec 11 '18 at 20:12