【问题标题】:Multiple "Duplicate identifier .." errors for a nodeJS projectnodeJS项目的多个“重复标识符..”错误
【发布时间】:2018-04-03 22:49:23
【问题描述】:

我正在使用 typeScript 开发一个 NodeJS 项目。在执行 npm install 后,在 tsc 命令中,我收到了类似的多个错误消息“重复标识符'Mongoose'”。

我的 tsconfig.json 如下

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

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

typeScript 是全局安装的。有谁知道为什么会这样? 谢谢!

【问题讨论】:

标签: javascript node.js typescript


【解决方案1】:

您需要在问题中包含更多内容。但是在某个地方你需要两次猫鼬或两次导入它。您是否将其安装在全局和模块中?

"typeRoots": [ “打字/全球”, “类型/模块”

【讨论】:

  • 我只用过一次。我之前没有“typeRoots”编译器选项。我找到了一个解决方案:在我将“typeRoots”与指定的路径放在一起之后,我删除了类型模块和 node_modules 并重新启动了 WebStorm。现在效果很好。但是我还是不明白为什么要放“typeRoots”编译选项。
  • TypeRoots 专门引用并包含模块angular.io/guide/aot-compiler
猜你喜欢
  • 2020-06-20
  • 2016-11-04
  • 2018-11-09
  • 1970-01-01
  • 2019-02-18
  • 2018-07-19
  • 2016-05-23
  • 2018-06-01
  • 2016-03-16
相关资源
最近更新 更多