Angular 4: ошибка TS2300: дубликат идентификатора 'PropertyKey' - PullRequest
2 голосов
/ 11 февраля 2020

Это один из тех дней, когда я просто открываю свой локальный хост и ожидаю, что все будет работать гладко, но нет!

В настоящее время я сталкиваюсь с 2 ошибками, когда запускаю приложение Angular 4 до http://localhost: 3000 / и я не уверен, почему возникают эти ошибки:

node_modules/typescript/lib/lib.d.ts(105,14): error TS2300: Duplicate identifier 'PropertyKey'.
typings/globals/core-js/index.d.ts(3,14): error TS2300: Duplicate identifier 'PropertyKey'.

Мой Windows 10 компьютер в настоящее время установлен с Версия узла 10.14.0 и npm версия 6.9.0 .

My package. json is:

{
  "name": "angular4-web-app",
  "version": "1.0.0",
  "author": "Mark",
  "description": "Angular 4 Web App on SystemJS",
  "homepage": "https://fakehomepage.com",
  "scripts": {
    "start": "tsc && concurrently \"tsc -w\" \"lite-server\" \"gulp sass\" \"gulp sass:watch\" ",
    "start:dev": "copy \"environment_dev.ts\" \"./app/shared/environment/global.constants.ts\" && npm run start",
    "start:qa": "copy \"environment_qa.ts\" \"./app/shared/environment/global.constants.ts\" && npm run start",
    "start:prod": "copy \"environment_prod.ts\" \"./app/shared/environment/global.constants.ts\" && npm run start",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "lint": "tslint ./app/**/*.ts -t verbose",
    "lite": "lite-server",
    "sass": "gulp sass",
    "sass:watch": "gulp sass:watch",
    "build:dev": "copy \"environment_dev.ts\" \"./app/shared/environment/global.constants.ts\" && gulp bundle-lower",
    "build:qa": "copy \"environment_qa.ts\" \"./app/shared/environment/global.constants.ts\" && gulp bundle-lower",
    "build:prod": "copy \"environment_prod.ts\" \"./app/shared/environment/global.constants.ts\" && gulp bundle-prod",
    "final": "gulp buildmini",
    "destroy": "gulp clean"
  },
  "license": "ISC",
  "dependencies": {
    "@angular/common": "4.4.7",
    "@angular/compiler": "4.4.7",
    "@angular/core": "4.4.7",
    "@angular/forms": "4.4.7",
    "@angular/http": "4.4.7",
    "@angular/platform-browser": "4.4.7",
    "@angular/platform-browser-dynamic": "4.4.7",
    "@angular/router": "4.4.7",
    "@ngx-translate/core": "^6.0.1",
    "@ngx-translate/http-loader": "0.0.3",
    "@types/highcharts": "^4.2.57",
    "angular2-highcharts": "^0.5.5",
    "animate.css": "^3.5.2",
    "bootstrap": "^3.4.1",
    "bootstrap-social": "^5.1.1",
    "core-js": "^2.4.1",
    "font-awesome": "~4.7.0",
    "gulp": "^3.9.1",
    "gulp-htmlmin": "^5.0.1",
    "highcharts": "^5.0.12",
    "jquery": "^3.4.1",
    "jquery-slimscroll": "^1.3.8",
    "lodash": "^4.17.15",
    "moment": "^2.18.1",
    "ng2-breadcrumb": "^0.5.14",
    "ng2-daterangepicker": "^2.0.8",
    "ngx-bootstrap": "^2.0.5",
    "ngx-infinite-scroll": "^0.5.1",
    "reflect-metadata": "^0.1.3",
    "rxjs": "5.4.2",
    "systemjs": "0.19.27",
    "zone.js": "^0.6.23"
  },
  "devDependencies": {
    "@types/node": "^6.0.60",
    "concurrently": "^3.1.0",
    "connect-history-api-fallback": "^1.3.0",
    "del": "^2.2.2",
    "gulp-clean-css": "^3.9.0",
    "gulp-concat": "^2.6.1",
    "gulp-sass": "^3.1.0",
    "gulp-sourcemaps": "^2.6.0",
    "gulp-systemjs-builder": "^0.15.0",
    "gulp-typescript": "^3.2.1",
    "gulp-uglify": "^3.0.0",
    "lite-server": "^2.3.0",
    "tslint": "^3.7.4",
    "typescript": "^2.2.2"
  },
  "repository": {
    "type": "git",
    "url": "https://bitbucket.org/mark/angular4-web-app.git"
  }
}

My tsconfig . json - это:

{
  "compilerOptions": {
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "module": "commonjs",
    "moduleResolution": "node",
    "noImplicitAny": true,
    "removeComments": true,
    "sourceMap": true,
    "suppressImplicitAnyIndexErrors": true,
    "target": "es5",
    "types" : []
  },
  "exclude": [
    "node_modules/*",
    "environment_dev.ts",
    "environment_qa.ts",
    "environment_prod.ts"
  ]
}

Полный журнал отладки :

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Users\\Mark\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'start:dev' ]
2 info using npm@6.9.0
3 info using node@v10.14.0
4 verbose run-script [ 'prestart:dev', 'start:dev', 'poststart:dev' ]
5 info lifecycle angular4-web-app@1.0.0~prestart:dev: angular4-web-app@1.0.0
6 info lifecycle angular4-web-app@1.0.0~start:dev: angular4-web-app@1.0.0
7 verbose lifecycle angular4-web-app@1.0.0~start:dev: unsafe-perm in lifecycle true
8 verbose lifecycle angular4-web-app@1.0.0~start:dev: PATH: C:\Users\Mark\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\Mark\Desktop\Development\Bitbucket\Angular 4 Web App\node_modules\.bin;C:\Users\Mark\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\local\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\Mark\bin;C:\Users\Mark\AppData\Local\SourceTree\app-2.1.10\lib\win32\x64;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client;C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Intel\iCLS Client;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files\Git\cmd;C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn;C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio;C:\Program Files\dotnet;C:\Program Files\Microsoft SQL Server\130\Tools\Binn;C:\HashiCorp\Vagrant\bin;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\TortoiseSVN\bin;C:\Program Files\PuTTY;C:\Program Files\nodejs;C:\WINDOWS\System32\OpenSSH;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn;C:\Program Files\Microsoft SQL Server\140\Tools\Binn;C:\Program Files\Microsoft SQL Server\140\DTS\Binn;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Python34\Scripts;C:\Users\Mark\AppData\Local\Programs\Python\Python38-32\Scripts;C:\Users\Mark\AppData\Local\Programs\Python\Python38-32;C:\Users\Mark\AppData\Local\Microsoft\WindowsApps;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Users\Mark\AppData\Roaming\npm;C:\Users\Mark\AppData\Local\Programs\Microsoft VS Code\bin;C:\Program Files\Git\usr\bin\vendor_perl;C:\Program Files\Git\usr\bin\core_perl
9 verbose lifecycle angular4-web-app@1.0.0~start:dev: CWD: C:\Users\Mark\Desktop\Development\Bitbucket\Angular 4 Web App
10 silly lifecycle angular4-web-app@1.0.0~start:dev: Args: [ '/d /s /c',
10 silly lifecycle   'copy "environment_dev.ts" "./app/shared/environment/global.constants.ts" && npm run start' ]
11 silly lifecycle angular4-web-app@1.0.0~start:dev: Returned: code: 2  signal: null
12 info lifecycle angular4-web-app@1.0.0~start:dev: Failed to exec start:dev script
13 verbose stack Error: angular4-web-app@1.0.0 start:dev: `copy "environment_dev.ts" "./app/shared/environment/global.constants.ts" && npm run start`
13 verbose stack Exit status 2
13 verbose stack     at EventEmitter.<anonymous> (C:\Users\Mark\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
13 verbose stack     at EventEmitter.emit (events.js:182:13)
13 verbose stack     at ChildProcess.<anonymous> (C:\Users\Mark\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:182:13)
13 verbose stack     at maybeClose (internal/child_process.js:962:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
14 verbose pkgid angular4-web-app@1.0.0
15 verbose cwd C:\Users\Mark\Desktop\Development\Bitbucket\Angular 4 Web App
16 verbose Windows_NT 10.0.18362
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Mark\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "start:dev"
18 verbose node v10.14.0
19 verbose npm  v6.9.0
20 error code ELIFECYCLE
21 error errno 2
22 error angular4-web-app@1.0.0 start:dev: `copy "environment_dev.ts" "./app/shared/environment/global.constants.ts" && npm run start`
22 error Exit status 2
23 error Failed at the angular4-web-app@1.0.0 start:dev script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 2, true ]

И вот как выглядит файловая система:

enter image description here

Ответы [ 2 ]

1 голос
/ 12 февраля 2020

Последнее исправление заключалось в том, чтобы сделать очевидный, но неортодоксальный метод полного удаления node_modules и последующего запуска npm install в этом приложении.

0 голосов
/ 11 февраля 2020

Попробуйте обновить @types/core-js с помощью команды npm install --save @types/core-js

, надеюсь, это помогло: D

...