gpt4 book ai didi

node.js - TS1086 : An accessor cannot be declared in ambient context in Angular 8 application using docker-compose

转载 作者:行者123 更新时间:2023-12-05 08:11:09 27 4
gpt4 key购买 nike

我在我的 Angular 8 应用程序中本地运行“ng serve”,一切正常。但是当我开始使用 docker 和 docker compose 运行应用程序时,在 @zxing/ngx-scanner 上出现“无法在环境上下文中声明访问器”错误

| ERROR in ../node_modules/@zxing/ngx-scanner/lib/browser-multi-format-continuous-reader.d.ts:12:9 - error TS1086: An accessor cannot be declared in an ambient context.
|
| 12 get isTorchAvailable(): Observable;
| ~~~~~~~~~~~~~~~~
| ../node_modules/@zxing/ngx-scanner/lib/zxing-scanner.component.d.ts:104:9 - error TS1086: An accessor cannot be declared in an ambient context.
|
| 104 get codeReader(): BrowserMultiFormatContinuousReader;
| ~~~~~~~~~~
| ../node_modules/@zxing/ngx-scanner/lib/zxing-scanner.component.d.ts:108:9 - error TS1086: An accessor cannot be declared in an ambient context.
|
| 108 set device(device: MediaDeviceInfo | null);
| ~~~~~~
| ../node_modules/@zxing/ngx-scanner/lib/zxing-scanner.component.d.ts:116:9 - error TS1086: An accessor cannot be declared in an ambient context.
|
| 116 get device(): MediaDeviceInfo | null;
| ~~~~~~
| ../node_modules/@zxing/ngx-scanner/lib/zxing-scanner.component.d.ts:120:9 - error TS1086: An accessor cannot be declared in an ambient context.
|
| 120 get formats(): BarcodeFormat[];
| ~~~~~~~
| ../node_modules/@zxing/ngx-scanner/lib/zxing-scanner.component.d.ts:126:9 - error TS1086: An accessor cannot be declared in an ambient context.
|
| 126 set formats(input: BarcodeFormat[]);
| ~~~~~~~
| ../node_modules/@zxing/ngx-scanner/lib/zxing-scanner.component.d.ts:130:9 - error TS1086: An accessor cannot be declared in an ambient context.
|
| 130 get hints(): Map<DecodeHintType, any>;
| ~~~~~
| ../node_modules/@zxing/ngx-scanner/lib/zxing-scanner.component.d.ts:134:9 - error TS1086: An accessor cannot be declared in an ambient context.
|
| 134 set hints(hints: Map<DecodeHintType, any>);
| ~~~~~
| ../node_modules/@zxing/ngx-scanner/lib/zxing-scanner.component.d.ts:138:9 - error TS1086: An accessor cannot be declared in an ambient context.
|
| 138 set isAutostarting(state: boolean | null);
| ~~~~~~~~~~~~~~
| ../node_modules/@zxing/ngx-scanner/lib/zxing-scanner.component.d.ts:142:9 - error TS1086: An accessor cannot be declared in an ambient context.
|
| 142 get isAutostarting(): boolean | null;
| ~~~~~~~~~~~~~~
| ../node_modules/@zxing/ngx-scanner/lib/zxing-scanner.component.d.ts:146:9 - error TS1086: An accessor cannot be declared in an ambient context.
|
| 146 set torch(on: boolean);
| ~~~~~
| ../node_modules/@zxing/ngx-scanner/lib/zxing-scanner.component.d.ts:150:9 - error TS1086: An accessor cannot be declared in an ambient context.
|
| 150 set enable(enabled: boolean);
| ~~~~~~
| ../node_modules/@zxing/ngx-scanner/lib/zxing-scanner.component.d.ts:154:9 - error TS1086: An accessor cannot be declared in an ambient context.
|
| 154 get enabled(): boolean;
| ~~~~~~~
| ../node_modules/@zxing/ngx-scanner/lib/zxing-scanner.component.d.ts:158:9 - error TS1086: An accessor cannot be declared in an ambient context.
|
| 158 get tryHarder(): boolean;
| ~~~~~~~~~
| ../node_modules/@zxing/ngx-scanner/lib/zxing-scanner.component.d.ts:162:9 - error TS1086: An accessor cannot be declared in an ambient context.
|
| 162 set tryHarder(enable: boolean);
| ~~~~~~~~~
|
| ** Angular Live Development Server is listening on 0.0.0.0:4200, open your browser on http://localhost:4200/ **
| ℹ 「wdm」: Failed to compile.

有人知道原因吗?在修复我的应用程序之前,我无法对其进行测试。

在我的 Angular 8 应用程序中启用 PWA 后,在 docker-compose 构建中遇到问题。通常,当我执行“ng serve”时编译成功,没有任何错误。

Package.json:

"@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/flex-layout": "^7.0.0-beta.23",
"@angular/forms": "^8.2.14",
"@angular/material": "^7.3.2",
"@angular/platform-browser": "^8.2.14",
"@angular/platform-browser-dynamic": "^8.2.14",
"@angular/router": "^8.2.14",
"@zxing/ngx-scanner": "3.0.0"

我找到了一些在 tsconfig.json 中添加 skipLibCheck 的解决方案,我不想跳过库检查。

"angularCompilerOptions": { 
"skipLibCheck": true
}

谁能帮我解决这个问题。提前致谢。

最佳答案

我可以看到您使用的是 Angular 的第 8 版。 ngx-scanner 最新版本不支持角度 8。

有两种解决方法:

  1. 将 angular 更新到版本 12 以使用最新的 ngx-scanner 版本。
  2. 将 ngx-scanner 降级到 ~2.0.1

关于node.js - TS1086 : An accessor cannot be declared in ambient context in Angular 8 application using docker-compose,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63572050/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com