作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在我的 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。
有两种解决方法:
关于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/
我是一名优秀的程序员,十分优秀!