/node_modules/moment-timezone/index.d.ts 中的错误 (47,77): ';'意料之中的。如何修复



我在Angular 4应用程序中工作,一切都很好,直到我克隆了我的repo并运行了npm install和ng serve

这个错误似乎是的问题

ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (47,77): ';' expected.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (47,92): ';' expected.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (47,111): ';' expected.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (48,27): ';' expected.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (48,49): ')' expected.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (48,71): Expression expected.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (48,74): ';' expected.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (48,75): Declaration or statement expected.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (48,79): ';' expected.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (49,32): ',' expected.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (49,54): Expression expected.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (49,64): ';' expected.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (50,20): ';' expected.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (51,27): Expression expected.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (51,37): ';' expected.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (53,29): Expression expected.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (53,38): ';' expected.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (64,1): Declaration or statement expected.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (47,92): 'MomentZoneOffset' only refers to a type, but is being used as a value here.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (47,113): Cannot find name 'never'.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (48,9): Cannot find name 'zonesForCountry'.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (48,25): Cannot find name 'T'.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (48,42): Cannot find name 'country'.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (48,51): Cannot find name 'string'.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (48,51): Left side of comma operator is unused and has no side effects.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (48,59): Cannot find name 'with_offset'.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (48,73): Cannot find name 'T'.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (48,77): Cannot find name 'T'.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (48,95): Cannot find name 'string'.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (48,106): Cannot find name 'never'.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (49,9): Cannot find name 'zonesForCountry'.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (49,25): Cannot find name 'country'.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (49,34): Cannot find name 'string'.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (49,42): Cannot find name 'with_offset'.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (49,56): Cannot find name 'boolean'.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (49,66): 'MomentZoneOffset' only refers to a type, but is being used as a value here.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (49,87): Cannot find name 'string'.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (50,9): Cannot find name 'countries'.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (50,22): Cannot find name 'string'.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (51,9): Cannot find name 'guess'.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (51,15): Cannot find name 'ignoreCache'.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (51,29): Cannot find name 'boolean'.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (51,39): Cannot find name 'string'.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (53,9): Cannot find name 'setDefault'.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (53,20): Cannot find name 'timezone'.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (53,31): Cannot find name 'string'.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (53,40): 'Moment' only refers to a type, but is being used as a value here.
ERROR in C:/Users/mypcuser/Desktop/myproject/node_modules/moment-timezone/index.d.ts (63,15): Cannot find name 'MomentTimezone'.
ERROR in C:/Users/mypcuser/Desktop/myproject/src/app/pipes/timePipes/moment-timezone.pipe.ts (10,37): Property 'tz' does not exist on type 'Moment'.
ERROR in C:/Users/mypcuser/Desktop/myproject/src/app/pipes/timePipes/moment-timezone-2.pipe.ts (13,34): Property 'tz' does not exist on type 'Moment'.
ERROR in C:/Users/mypcuser/Desktop/myproject/src/app/pipes/timePipes/moment-timezone.pipe.ts (10,37): Property 'tz' does not exist on type 'Moment'.
ERROR in C:/Users/mypcuser/Desktop/myproject/src/app/pipes/timePipes/moment-timezone-2.pipe.ts (13,34): Property 'tz' does not exist on type 'Moment'.

所以我研究了一下,发现了这个--->如何修复node_modules/@types/moment-timezone/moment-time zone.d.ts(50.73(中的此错误

但对我来说,它没有起作用,我更新了很多东西,清理了缓存,重新安装了即时时区,问题仍然存在。

这是我的包.json

{
"name": "myproject",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@agm/core": "1.0.0-beta.1",
"@angular/animations": "^4.4.7",
"@angular/cdk": "^2.0.0-beta.12",
"@angular/common": "^4.4.6",
"@angular/compiler": "4.4.6",
"@angular/core": "4.4.6",
"@angular/flex-layout": "2.0.0-beta.9",
"@angular/forms": "4.4.6",
"@angular/http": "^4.4.6",
"@angular/material": "^2.0.0-beta.12",
"@angular/platform-browser": "4.4.6",
"@angular/platform-browser-dynamic": "4.4.6",
"@angular/router": "4.4.6",
"@mdi/font": "^3.5.95",
"@ngx-translate/core": "8.0.0",
"@ngx-translate/http-loader": "2.0.0",
"@swimlane/ngx-datatable": "9.3.1",
"@types/chart.js": "^2.7.54",
"@types/geojson": "^7946.0.1",
"@types/googlemaps": "^3.30.7",
"@types/hammerjs": "^2.0.36",
"@types/jspdf": "^1.2.2",
"@types/moment-timezone": "^0.5.7",
"angular-calendar": "0.21.2",
"angular-notifier": "^2.0.0",
"angular-perfect-scrollbar": "^0.2.0",
"angular-tree-component": "5.0.0",
"angular-xregexp": "^1.0.0",
"angular2-datetimepicker": "^1.1.1",
"angular2-jwt": "^0.2.3",
"angular2-text-mask": "^9.0.0",
"chart.js": "^2.8.0",
"chartjs-plugin-zoom": "^0.7.0",
"core-js": "2.5.1",
"d3": "4.11.0",
"docx": "^4.4.0",
"double-slider": "^2.0.0",
"dragula": "3.7.2",
"file-saver": "^2.0.2",
"hammerjs": "2.0.8",
"intl": "1.2.5",
"json-server": "^0.15.0",
"jsonwebtoken": "^8.1.1",
"jspdf": "^1.4.1",
"jszip": "^3.1.5",
"lrm-graphhopper": "^1.3.0",
"moment": "^2.22.2",
"moment-timezone": "^0.5.0",
"ng-pick-datetime": "^4.3.4",
"ng-tiny-scrollbar": "^0.10.1",
"ng2-charts": "1.6.0",
"ng2-dragula": "1.5.0",
"ng2-file-upload": "1.2.1",
"ng2-order-pipe": "^0.1.5",
"ng2-toasty": "^4.0.3",
"ng2-validation": "4.2.0",
"ng4-datetimepicker": "^1.0.6",
"ngx-bootstrap-product-tour": "^1.0.6",
"ngx-cookie-service": "^1.0.10",
"ngx-export-as": "^1.4.0",
"ngx-perfect-scrollbar": "^4.9.6",
"ngx-quill": "1.3.5",
"node-sass": "^4.14.1",
"particles.js": "^2.0.0",
"pdfmake": "^0.1.57",
"perfect-scrollbar": "^0.8.1",
"polyline-encoded": "0.0.8",
"primeicons": "^1.0.0-beta.10",
"primeng": "^6.1.2",
"rxjs": "5.4.3",
"screenfull": "3.3.1",
"simple-scrollbar": "^0.4.0",
"simplebar": "^2.5.1",
"time-ago-pipe": "^1.3.2",
"videogular2": "^5.6.3",
"zone.js": "^0.8.12"
},
"devDependencies": {
"@angular/cli": "^1.4.4",
"@angular/compiler-cli": "4.4.6",
"@angular/language-service": "4.4.6",
"@types/core-js": "^2.5.2",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "~3.1.1",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "^5.1.2",
"ts-node": "~3.2.0",
"tslint": "^5.20.1",
"typescript": "2.3.3",
"wd": "^1.11.2",
"wd-bridge": "0.0.2"
}
}

非常感谢你的帮助!

更改package.json文件中的代码。

从目录中删除node_modulespackage-lock.json

而不是更改版本并运行NPM安装

"@types/moment-timezone": "^0.5.7",

"moment-timezone": "0.5.23",

对于初学者,我会检查npm环境是否不同,或者全局包是否扰乱了您的本地包。

否则,请尝试为即时时区安装其他版本。

相关内容

  • 没有找到相关文章