错误 ngx-daterangepicker-material 无法在环境上下文中声明访问器

Posted

技术标签:

【中文标题】错误 ngx-daterangepicker-material 无法在环境上下文中声明访问器【英文标题】:ERROR ngx-daterangepicker-material An accessor cannot be declared in an ambient context 【发布时间】:2020-07-29 13:31:44 【问题描述】:

你能帮我解决这个错误吗?这是我的 package.json 错误 我不断收到此错误:

node_modules/ngx-daterangepicker-material/daterangepicker.component.d.ts(59,9) 中的错误:错误 TS1086:无法在环境上下文中声明访问器。

    "@agm/core": "^1.0.0-beta.7",
    "@angular/animations": "~8.0.3",
    "@angular/cdk": "^8.1.1",
    "@angular/common": "~8.0.3",
    "@angular/compiler": "~8.0.3",
    "@angular/core": "~8.0.3",
    "@angular/forms": "~8.0.3",
    "@angular/material": "^8.1.1",
    "@angular/material-moment-adapter": "^8.1.1",
    "@angular/platform-browser": "~8.0.3",
    "@angular/platform-browser-dynamic": "~8.0.3",
    "@angular/router": "~8.0.3",
    "@fortawesome/angular-fontawesome": "^0.4.0",
    "@fortawesome/fontawesome-svg-core": "^1.2.28",
    "@fortawesome/free-solid-svg-icons": "^5.13.0",
    "@syncfusion/ej2-angular-calendars": "^17.4.51",
    "@types/jquery": "^3.3.35",
    "acorn": "^6.4.1",
    "angular-hammer": "^2.2.0",
    "angular-svg-icon": "^8.0.0",
    "bootstrap": "^4.3.1",
    "mat-range-datepicker": "^1.0.5",
    "moment": "^2.24.0",
    "ng2-datepicker": "^2.3.1",
    "ng2-tooltip-directive": "^2.9.20",
    "ngx-daterangepicker-material": "^2.2.1",
    "ngx-drag-scroll": "^8.0.0-beta.2",
    "ngx-infinite-scroll": "^8.0.2",
    "ngx-material-timepicker": "^5.5.1",
    "popper.js": "^1.15.0",
    "pretty-checkbox": "^3.0.3",
    "rxjs": "~6.4.0",
    "tslib": "^1.11.1",
    "xlsx": "^0.15.6",
    "zone.js": "~0.9.1"
  ,
  "devDependencies": 
    "@angular-devkit/build-angular": "~0.800.6",
    "@angular/cli": "~8.0.6",
    "@angular/compiler-cli": "~8.0.3",
    "@angular/language-service": "~8.0.3",
    "@types/jasmine": "~3.3.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "^5.2.2",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.1.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.5.3",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.15.0",
    "typescript": "~3.4.3"
  
``
thank you

【问题讨论】:

我在为 Tag npm 安装 ngx-chips 时遇到了同样的问题。现在我也不能编译并得到同样的问题 【参考方案1】:

对于metronic-angular 6.1.8,我花了8个小时,但我解决了。

已删除 package-lock.json 删除了 node_modules 文件夹 npm 安装

如果你执行ng serve收到TS1086错误,别担心...

现在启动:

npm i ngx-daterangepicker-material@2.2.0 npm i moment@2.18.1

重新启动`ng服务享受! ;)

第一个解决方案解决了开发部分,但是在部署过程中出现了问题。最终的解决方案是:

已删除 package-lock.json 删除了 node_modules 文件夹 在 package.json 中删除 (^) 库 ngx-daterangepicker-material ("ngx-daterangepicker-material": "^2.1.11" -> "ngx-daterangepicker-material": "2.1.11") 将版本时刻从 ^2.24.0 增加到 2.25.3(删除 ^, "moment": "^2.24.0" -> "moment": "2.25.3",

现在一切正常... ng serve 和 yarn build。 ;)

【讨论】:

我不敢相信我正在寻找的答案来自你 Pasquale!在***上随机选择的答案在这里相遇真是令人难以置信!无论如何,它对我有用,非常感谢,希望尽快收到您的来信! 这个答案为我节省了数小时和数小时的搜索时间!【参考方案2】:

我通过以下两个步骤解决了这个问题

    首先从package.json中删除"ngx-daterangepicker-material": "^2.2.1"

    运行npm i ngx-daterangepicker-material@2.2.0

    “服务”

编译成功

【讨论】:

【参考方案3】:

我刚刚通过以下步骤解决了这个问题

    首先,从项目文件夹中删除 node_modules 文件夹

    在你的 package.json 中替换上面的 ngx-daterangepicker-material 版本 2.2.1到2.1.9,喜欢

删除 -> "ngx-daterangepicker-material": "^2.2.1",

添加 -> "ngx-daterangepicker-material": "^2.1.9",

    在终端运行 npm install 命令然后编译

编译成功

【讨论】:

奇怪的是这解决了这个问题。对我来说,这实际上也解决了这个问题,但我无法解释如何......【参考方案4】:

要解决此问题,我们必须检查您项目中使用的angular version。根据角度版本,我们必须更新package.json 中的ngx-daterangepicker-material 库。

检查以下内容,为您的 Angular 项目找到合适的库版本:

版本:

Angular      ngx-daterangepicker-material
>=9.0.0      v2.3.x and v3.x
<9.0.0       v2.2.x and below

参考: https://www.npmjs.com/package/ngx-daterangepicker-material

如果您在正常的"ng --prod" 中遇到javascript heap out of memory 问题,请运行以下评论以进行产品构建:

node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng build client --prod

【讨论】:

更换版本问题依旧 请在 package.json 更改完成后执行“npm install”并检查角度版本是否小于 9 使用“ngx-daterangepicker-material”版本 2.2.0 并检查构建命令. 解决我的问题的答案已经出来了,在 pasquale carucci 的解释中。谢谢【参考方案5】:

您好,我也有同样的问题,但我尝试更改版本,但不起作用


"name": "metronic-angular",
"version": "6.1.8",
"description": "Packages used by Angular",
"scripts": 
    "ng": "ng",
    "start": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng serve",
    "build": "ng build --prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "bundle-report": "webpack-bundle-analyzer dist/stats.json",
    "rtl": "webpack"
,
"private": true,
"dependencies": 
    "@angular/animations": "^8.2.14",
    "@angular/cdk": "^8.2.3",
    "@angular/common": "^8.2.14",
    "@angular/compiler": "^8.2.14",
    "@angular/core": "^8.2.14",
    "@angular/forms": "^8.2.14",
    "@angular/platform-browser": "^8.2.14",
    "@angular/platform-browser-dynamic": "^8.2.14",
    "@angular/platform-server": "^8.2.14",
    "@angular/router": "^8.2.14",
    "@fortawesome/fontawesome-free": "^5.12.0",
    "@ng-bootstrap/ng-bootstrap": "^5.1.5",
    "@ngrx/effects": "^8.6.0",
    "@ngrx/entity": "^8.6.0",
    "@ngrx/router-store": "^8.6.0",
    "@ngrx/store": "^8.6.0",
    "@ngrx/store-devtools": "^8.6.0",
    "@ngx-loading-bar/core": "^4.2.0",
    "@ngx-translate/core": "^11.0.1",
    "@types/lodash": "^4.14.149",
    "angular-in-memory-web-api": "^0.8.0",
    "bootstrap": "^4.4.1",
    "chart.js": "^2.9.3",
    "chartist": "^0.11.4",
    "classlist.js": "^1.1.20150312",
    "core-js": "^3.6.2",
    "hammerjs": "^2.0.8",
    "highlight.js": "^9.17.1",
    "lodash": "^4.17.11",
    "material-design-icons": "^3.0.1",
    "moment": "^2.24.0",
    "ng-inline-svg": "^9.2.2",
    "ngrx-store-freeze": "^0.2.4",
    "ngx-clipboard": "^12.3.0",
    "ngx-daterangepicker-material": "^2.11.1", // change version but the problem persist
    "ngx-highlightjs": "^3.0.3",
    "ngx-perfect-scrollbar": "^8.0.0",
    "ngx-permissions": "^7.0.3",
    "object-path": "^0.11.4",
    "perfect-scrollbar": "^1.4.0",
    "popper.js": "^1.16.0",
    "rxjs": "^6.5.4",
    "socicon": "^3.0.5",
    "tooltip.js": "^1.3.3",
    "tslib": "^1.10.0",
    "web-animations-js": "^2.3.2",
    "zone.js": "~0.9.1"
,
"devDependencies": 
    "@angular-devkit/build-angular": "^0.800.6",
    "@angular/cli": "^8.3.22",
    "@angular/compiler-cli": "^8.2.14",
    "@angular/language-service": "^8.2.14",
    "@angular/material": "^8.2.3",
    "@angular/material-moment-adapter": "^8.2.3",
    "@ngrx/schematics": "^8.6.0",
    "@types/chartist": "^0.9.46",
    "@types/highlight.js": "^9.12.3",
    "@types/jasmine": "^3.5.0",
    "@types/jasminewd2": "^2.0.8",
    "@types/node": "^12.12.24",
    "@types/object-path": "^0.11.0",
    "codelyzer": "^5.2.1",
    "css-loader": "^3.4.1",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "^4.4.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "^2.1.1",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.5.1",
    "node-sass": "^4.13.0",
    "protractor": "~5.4.2",
    "ts-node": "~8.2.0",
    "tslint": "~5.17.0",
    "typescript": "~3.4.5",
    "webpack-bundle-analyzer": "^3.6.0",
    "webpack-cli": "^3.3.10",
    "webpack-messages": "^2.0.4",
    "webpack-rtl-plugin": "^2.0.0"

【讨论】:

【参考方案6】:

我尝试了上述所有建议的解决方案,但它们并没有为我解决问题。 但是,我通过简单地更改包版本解决了这个问题:

“ngx-daterangepicker-material”:“2.1.9”

然后 - 删除 node_modules 文件夹 - npm 安装 - ng服务工作 - ng build --prod --aot=true 也有效

【讨论】:

【参考方案7】:

    首先从 package.json 中删除 "ngx-daterangepicker-material": "^2.2.1"

    运行“npm i ngx-daterangepicker-material@2.2.0”

【讨论】:

以上是关于错误 ngx-daterangepicker-material 无法在环境上下文中声明访问器的主要内容,如果未能解决你的问题,请参考以下文章

Informix 错误:发生了语法错误。错误代码:-201

我收到一个错误:“MetaMask - RPC 错误:错误:错误:[ethjs-rpc] rpc 错误与有效负载”

错误精灵错误跟踪器错误

网页打开显示错误500是啥意思

PHP错误处理

PHP的错误处理