重复标识符错误Popper.js

时间:2017-07-31 22:06:12

标签: node.js angular typescript npm duplicates

我无法修复此错误或确定原因。没有代码发生变化,所以我认为它是NPM包更新的结果。这是控制台的错误日志。这适用于Angular2应用程序。

ERROR in [at-loader] ./node_modules/@types/popper.js/index.d.ts:6:19 
    TS2300: Duplicate identifier 'Popper'.

ERROR in [at-loader] ./node_modules/@types/popper.js/index.d.ts:89:15 
    TS2300: Duplicate identifier 'Popper'.

ERROR in [at-loader] ./node_modules/@types/popper.js/index.d.ts:104:3 
    TS2300: Duplicate identifier 'default'.

ERROR in [at-loader] ./node_modules/popper.js/index.d.ts:8:19 
    TS2300: Duplicate identifier 'Popper'.

ERROR in [at-loader] ./node_modules/popper.js/index.d.ts:113:15 
    TS2300: Duplicate identifier 'Popper'.

ERROR in [at-loader] ./node_modules/popper.js/index.d.ts:120:43 
    TS2694: Namespace 'Popper' has no exported member 'ReferenceObject'.

ERROR in [at-loader] ./node_modules/popper.js/index.d.ts:130:3 
    TS2300: Duplicate identifier 'default'.

这是我的tsconfig.json文件:

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [ "es2015", "dom" ],
    "noImplicitAny": true,
    "suppressImplicitAnyIndexErrors": true,
    "typeRoots": [
      "../node_modules/@types/"
    ]
  },
  "compileOnSave": true,
  "exclude": [
    "node_modules/*",
    "**/*-aot.ts"
  ]
}

这是我要求的package.json文件。我认为问题是其中一个软件包正在升级到不稳定版本,因为我过去没有收到过这个错误:

{
  "name": "truerec-verifier-landing-page",
  "version": "1.0.0",
  "description": "TrueRec verifier web.",
  "scripts": {
    "start": "webpack-dev-server --inline --progress --port 8080",
    "test": "karma start karma.webpack.conf.js",
    "build": "rm -rf dist/* && webpack --config config/webpack.prod.js --bail",
    "dev": "rm -rf dist/* && webpack --config config/webpack.dev.js --bail"
  },
  "keywords": [],
  "author": "",
  "license": "MIT",
  "dependencies": {
    "@angular/animations": "~4.1.1",
    "@angular/common": "~4.1.1",
    "@angular/compiler": "~4.1.1",
    "@angular/compiler-cli": "~4.1.1",
    "@angular/core": "~4.1.1",
    "@angular/forms": "~4.1.1",
    "@angular/http": "~4.1.1",
    "@angular/platform-browser": "~4.1.1",
    "@angular/platform-browser-dynamic": "~4.1.1",
    "@angular/platform-server": "~4.1.1",
    "@angular/router": "~4.1.1",
    "@angular/tsc-wrapped": "~4.1.1",
    "@angular/upgrade": "~4.1.1",
    "angular-in-memory-web-api": "~0.3.1",
    "angular2-recaptcha": "^0.4.1",
    "core-js": "^2.4.1",
    "jquery": "^3.2.1",
    "js-sha3": "^0.5.7",
    "ng2-pdf-viewer": "^1.1.0",
    "ng2-semantic-ui": "^0.8.4",
    "ng2-toastr": "^4.1.2",
    "ngx-cookie": "^1.0.0",
    "pdfjs-dist": "^1.8.430",
    "rxjs": "5.0.1",
    "zone.js": "0.8.12"
  },
  "devDependencies": {
    "@types/google.analytics": "0.0.33",
    "@types/jasmine": "2.5.36",
    "@types/node": "^6.0.45",
    "angular2-template-loader": "^0.6.0",
    "awesome-typescript-loader": "^3.0.4",
    "css-loader": "^0.26.1",
    "extract-text-webpack-plugin": "2.0.0-beta.5",
    "file-loader": "^0.9.0",
    "html-loader": "^0.4.3",
    "html-webpack-plugin": "^2.16.1",
    "jasmine": "~2.4.1",
    "jasmine-core": "~2.4.1",
    "karma": "^1.3.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "karma-phantomjs-launcher": "^1.0.2",
    "karma-sourcemap-loader": "^0.3.7",
    "karma-webpack": "^2.0.1",
    "less": "^2.7.2",
    "less-loader": "^4.0.4",
    "lodash": "^4.16.2",
    "null-loader": "^0.1.1",
    "phantomjs-prebuilt": "2.1.13",
    "protractor": "~4.0.14",
    "raw-loader": "^0.5.1",
    "request": "^2.81.0",
    "resolve-url-loader": "^2.0.2",
    "rimraf": "^2.5.4",
    "style-loader": "^0.13.1",
    "to-string-loader": "^1.1.5",
    "tslint": "^3.15.1",
    "typescript": "~2.3.0",
    "webpack": "2.2.1",
    "webpack-dev-server": "2.4.1",
    "webpack-merge": "^3.0.0"
  },
  "repository": {}
}

1 个答案:

答案 0 :(得分:2)

昨天我遇到了同样的问题,当时我将一个repo克隆到一台新机器上并进行了NPM安装来获取软件包 - 同样的错误。我的项目也使用ng2-semantic-ui包。 Ng2-semantic-ui依赖于Popper.js和@types \ popper(typescript定义)。

"dependencies": {
   "@angular/common": "^4.1.0",
   "@angular/core": "^4.1.0",
   "@angular/forms": "^4.1.0",
   "@types/popper.js": "^1.8.0",
   "element-closest": "^2.0.2",
   "popper.js": "^1.0.6",
    "rxjs": "^5.0.1"
},

我能够比较我的原始包和新的包我注意到popper.js现在包含了typescript定义(index.d.ts)。看起来它们是在1.11.1中引入的 - 我的工作版本上有1.10.8,而我的机器上的1.12.1带有“破损”版本(与你的版本相同)。

错误来源和重复标识符是popper.js的重复类型定义。

我将在ng2-semantic-ui上打开一个问题,看看我们是否可以删除对@ types / popper.js的依赖,因为最新版本的popper.js不需要它。与此同时,我删除了@ types / popper.js,并且能够获得良好的构建。希望这有帮助!

更新:此问题似乎在3周前的0.9.4版(问题195)(https://github.com/edcarroll/ng2-semantic-ui/releases/tag/v0.9.4)中的修补程序中得到解决。在package.json中更新你的依赖版本,你应该很高兴。