Hongbo Miao Hongbo Miao - 4 months ago 64
JSON Question

How to ignore the error of the typings folder?

I added

mongoose
and also its typings.

When I
npm run watch
, I got the error in my terminal:


ERROR in /my-project/typings/globals/mongoose/index.d.ts (5,28): error
TS2307: Cannot find module 'mongodb'.

ERROR in /my-project/typings/globals/mongoose/index.d.ts (2071,32):
error TS2304: Cannot find name 'MongoosePromise'.


I changed my tsconfig.json "exclude" part to

"exclude": [
"typings/main.d.ts",
"typings/main",
"typings/globals/mongoose/index.d.ts",
"node_modules"
],

"exclude": [
"typings/main.d.ts",
"typings/main",
"typings/globals/mongoose",
"node_modules"
],

"exclude": [
"typings/main.d.ts",
"typings/main",
"typings/globals",
"node_modules"
],


Neither of above works.

And if I change to

"exclude": [
"typings",
"node_modules"
],


It will give me MORE errors (several pages).

How to ignore the error in the typing folder? Thanks

Answer

You should be:

  1. Make sure mongodb and node definitions installed:

    typings install dt~node dt~mongodb --global

  2. Use the promise library

    mongoose.Promise = your_promise

If you're using the default mpromise, you should:

typings install dt~mongoose-promise --global

You can find out more at here

Hop this help!