-1

I am working on a NodeJS project using typeScript. after doing npm install, at tsc command, i got similar multiple errors with the message "Duplicate Identifier 'Mongoose'".

My tsconfig.json is the following

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es6",
    "outDir": "./build",
    "noImplicitAny" : true,
    "sourceMap": true,
    "typeRoots": [
      "typings/global",
      "typings/modules"
    ]

//    "skipLibCheck": true
  },
  "compileOnSave": true,
  "exclude": [
    "node_modules"
  ]
}

The typeScript is installed globally. Does anybody knows why is happening this? Thank you!

Suren Srapyan
  • 66,568
  • 14
  • 114
  • 112
  • https://stackoverflow.com/questions/31322525/typescript-confusing-duplicate-identifier-error-message – skylize Nov 18 '17 at 02:37
  • Possible duplicate of [Typescript, confusing "duplicate identifier" error message](https://stackoverflow.com/questions/31322525/typescript-confusing-duplicate-identifier-error-message) – skylize Nov 18 '17 at 02:37

1 Answers1

0

You need to include more in your question. But somewhere you are requiring mongoose twice or importing it twice. Do you have it installed in global AND in modules?

"typeRoots": [ "typings/global", "typings/modules"

Hunter
  • 388
  • 4
  • 11
  • I am using it just once. I didn't have "typeRoots" compiler options before. I found a solution: After I had put "typeRoots" with the specified paths, i had deleted typings module and node_modules and restarted the WebStorm. It works well now. But I still do not understand why should I put the "typeRoots" compiler option. – Stefan Scurtu Oct 23 '17 at 12:02
  • TypeRoots specifically references and includes the module https://angular.io/guide/aot-compiler – Hunter Oct 23 '17 at 12:52