【问题标题】:error TS2300: Duplicate identifier 'export='错误 TS2300:重复标识符“导出 =”
【发布时间】:2016-12-27 06:49:21
【问题描述】:

我使用 angular/universal-starter 作为启动器,它使用 TypeScript 2 和 Webpack 2。

我添加了包bluebirdnodemailer。添加这些包和相关类型后:

"@types/bluebird": "3.0.31",
"@types/nodemailer": "1.3.30",

它在终端中给了我这个错误:

错误 /project/node_modules/@types/nodemailer/node_modules/@types/bluebird/index.d.ts (772,5):错误 TS2300:重复标识符“export=”。

/project/node_modules/@types/bluebird/index.d.ts (772,1) 中的错误: 错误 TS2300:重复标识符“export=”。

[不确定是否有帮助] 注意安装后@types/nodemailer,@type/nodemailer 有自己的 node_modules 文件夹,包括 @type/bluebird(这是一个旧蓝鸟分型 2.0.0 版):

我的 tsconfig.json 文件:

{
  "compilerOptions": {
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "module": "commonjs",
    "removeComments": true,
    "sourceMap": true,
    "lib": ["es6", "dom"]
  },
  "include": [
    "node_modules/@types/**/*.d.ts",
    "src/**/*.ts"
  ],
  "exclude": [
    "node_modules",
    "!node_modules/@types/**/*.d.ts"
  ],
  "compileOnSave": false,
  "buildOnSave": false,
  "atom": {
    "rewriteTsconfig": false
  }
}

我该如何解决这个错误?谢谢

【问题讨论】:

  • 我最近遇到了同样的错误消息,但使用 jquery,并在 tsconfig.json 中添加 typeRoots 解决了它。更多信息Minko Gechev's blog

标签: angular typescript webpack typescript2.0 angular2-universal


【解决方案1】:

不确定是什么原因造成的。但是在将它们全部更新到新版本包之后:

"bluebird": "3.4.1",
"nodemailer": "2.5.0",
"@types/bluebird": "3.0.32",
"@types/nodemailer": "1.3.31",

而且我没有更改任何其他代码。问题消失了。

【讨论】: