错误 TS1086:无法在环境上下文中声明访问器
Posted
技术标签:
【中文标题】错误 TS1086:无法在环境上下文中声明访问器【英文标题】:ERROR TS1086: An accessor cannot be declared in an ambient context 【发布时间】:2021-07-09 06:06:46 【问题描述】:TS1086:无法在环境上下文中声明访问器。
当我尝试使用运行项目时,我遇到了这些错误,我尝试过 运行 npm install 并尝试先清理缓存 使用 npm clean 命令然后再次使用 npm install 安装我仍然收到这些错误
请提前帮助和感谢
ERROR in node_modules/@rosen-group/ngx-onboarding/lib/models/onboarding-item-container.model.d.ts(14,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/@rosen-group/ngx-onboarding/lib/models/onboarding-item-container.model.d.ts(18,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/@rosen-group/ngx-onboarding/lib/models/onboarding-item-container.model.d.ts(22,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/@rosen-group/ngx-onboarding/lib/models/onboarding-item-container.model.d.ts(26,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/@rosen-group/ngx-onboarding/lib/models/onboarding-item-container.model.d.ts(30,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/@rosen-group/ngx-onboarding/lib/onboarding-button.component.d.ts(15,9): error TS1086: An accessor cannot be declared in
an ambient context.
node_modules/@rosen-group/ngx-onboarding/lib/onboarding-button.component.d.ts(19,9): error TS1086: An accessor cannot be declared in
an ambient context.
node_modules/@rosen-group/ngx-onboarding/lib/services/build-in-translator.service.d.ts(18,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/@rosen-group/ngx-onboarding/lib/services/onboarding.service.d.ts(42,9): error TS1086: An accessor cannot be declared in
an ambient context.
node_modules/@rosen-group/ngx-onboarding/lib/services/translator-base.service.d.ts(16,18): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/@rosen-group/ngx-onboarding/lib/services/window-ref.service.d.ts(5,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/ng2-pdf-viewer/src/app/pdf-viewer/pdf-viewer.component.d.ts(5,10): error TS2305: Module '"C:/Users/RKC/Documents/lmsclient-master/node_modules/pdfjs-dist/types/pdf"' has no exported member 'PDFDocumentProxy'.
node_modules/ng2-pdf-viewer/src/app/pdf-viewer/pdf-viewer.component.d.ts(5,28): error TS2305: Module '"C:/Users/RKC/Documents/lmsclient-master/node_modules/pdfjs-dist/types/pdf"' has no exported member 'PDFSource'.
node_modules/ng2-pdf-viewer/src/app/pdf-viewer/pdf-viewer.component.d.ts(5,39): error TS2305: Module '"C:/Users/RKC/Documents/lmsclient-master/node_modules/pdfjs-dist/types/pdf"' has no exported member 'PDFProgressData'.
node_modules/ng2-pdf-viewer/src/app/pdf-viewer/pdf-viewer.module.d.ts(1,10): error TS2305: Module '"C:/Users/RKC/Documents/lmsclient-master/node_modules/pdfjs-dist/types/pdf"' has no exported member 'PDFJSStatic'.
node_modules/ng2-pdf-viewer/src/app/pdf-viewer/pdf-viewer.module.d.ts(5,10): error TS2305: Module '"C:/Users/RKC/Documents/lmsclient-master/node_modules/pdfjs-dist/types/pdf"' has no exported member 'PDFJSStatic'.
node_modules/ng2-pdf-viewer/src/app/pdf-viewer/pdf-viewer.module.d.ts(5,23): error TS2305: Module '"C:/Users/RKC/Documents/lmsclient-master/node_modules/pdfjs-dist/types/pdf"' has no exported member 'PDFDocumentProxy'.
node_modules/ng2-pdf-viewer/src/app/pdf-viewer/pdf-viewer.module.d.ts(5,41): error TS2305: Module '"C:/Users/RKC/Documents/lmsclient-master/node_modules/pdfjs-dist/types/pdf"' has no exported member 'PDFViewerParams'.
node_modules/ng2-pdf-viewer/src/app/pdf-viewer/pdf-viewer.module.d.ts(5,58): error TS2305: Module '"C:/Users/RKC/Documents/lmsclient-master/node_modules/pdfjs-dist/types/pdf"' has no exported member 'PDFPageProxy'.
node_modules/ng2-pdf-viewer/src/app/pdf-viewer/pdf-viewer.module.d.ts(5,72): error TS2305: Module '"C:/Users/RKC/Documents/lmsclient-master/node_modules/pdfjs-dist/types/pdf"' has no exported member 'PDFSource'.
node_modules/ng2-pdf-viewer/src/app/pdf-viewer/pdf-viewer.module.d.ts(5,83): error TS2305: Module '"C:/Users/RKC/Documents/lmsclient-master/node_modules/pdfjs-dist/types/pdf"' has no exported member 'PDFProgressData'.
node_modules/ng2-pdf-viewer/src/app/pdf-viewer/pdf-viewer.module.d.ts(5,100): error TS2305: Module '"C:/Users/RKC/Documents/lmsclient-master/node_modules/pdfjs-dist/types/pdf"' has no exported member 'PDFPromise'.
node_modules/ng2-smart-table/lib/components/tbody/tbody.component.d.ts(30,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/ngx-editor/app/ngx-editor/ngx-editor-toolbar/ngx-editor-toolbar.component.d.ts(3,31): error TS2307: Cannot find module 'ngx-bootstrap'.
node_modules/ngx-quicklink/src/link.directive.d.ts(13,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/ngx-quicklink/src/link.directive.d.ts(14,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/ngx-show-hide-password/lib/show-hide-status.directive.d.ts(16,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/pdfjs-dist/types/display/annotation_storage.d.ts(30,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/pdfjs-dist/types/display/api.d.ts(595,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/pdfjs-dist/types/display/api.d.ts(599,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/pdfjs-dist/types/display/api.d.ts(603,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/pdfjs-dist/types/display/api.d.ts(798,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/pdfjs-dist/types/display/api.d.ts(802,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/pdfjs-dist/types/display/api.d.ts(948,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/pdfjs-dist/types/display/api.d.ts(1155,9): error TS186: An accessor cannot be declared in an ambient context.086: An accessor cannot be declared in an ambient context. 86: An accessor cannot be declared in an ambient context.
node_modules/quill-delta/dist/Delta.d.ts(1,8): error TS1192: Modu86: An accessor cannot be declared in an ambient context.le '"C:/Users/RKC/Documents/lmsclient-master/node_modules/fast-di86: An accessor cannot be declared in an ambient context.ff/diff"' has no default export. 086: An accessor cannot be declared in an ambient context.
src/app/pages/users/teacherDetails/teacherDetails.component.ts(23086: An accessor cannot be declared in an ambient context.,26): error TS2307: Cannot find module 'ngx-bootstrap'. le '"C:/Users/RKC/Documents/lmsclient-master/node_modules/fast-diff/
src/app/pages/users/user/user.component.ts(23,26): error TS2307:
Cannot find module 'ngx-bootstrap'
package.json
"name": "learningmgmtsystem",
"version": "1.0.0",
"license": "LICENCE",
"repository":
"type": "git",
"url": "git+https://github.com/akveo/ngx-admin.git"
,
"bugs":
"url": "https://github.com/akveo/ngx-admin-bundle-support/issues"
,
"scripts":
"ng": "ng",
"conventional-changelog": "conventional-changelog",
"start": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng serve --host=0.0.0.0 --disable-host-check",
"build": "ng build",
"build:prod": "npm run build -- --prod --aot ",
"test": "ng test",
"test:coverage": "rimraf coverage && npm run test -- --code-coverage",
"lint": "ng lint",
"lint:fix": "ng lint ngx-admin-demo --fix",
"lint:styles": "stylelint ./src/**/*.scss",
"lint:ci": "npm run lint && npm run lint:styles",
"pree2e": "webdriver-manager update --standalone false --gecko false",
"e2e": "ng e2e",
"docs": "compodoc -p src/tsconfig.app.json -d docs",
"docs:serve": "compodoc -p src/tsconfig.app.json -d docs -s",
"prepush": "npm run lint:ci",
"release:changelog": "npm run conventional-changelog -- -p angular -i CHANGELOG.md -s"
,
"dependencies":
"@agm/core": "^1.0.0-beta.7",
"@angular/animations": "^8.2.3",
"@angular/cdk": "^8.1.3",
"@angular/common": "^8.2.2",
"@angular/compiler": "^8.2.2",
"@angular/core": "^8.2.2",
"@angular/forms": "^8.2.2",
"@angular/material": "^8.1.3",
"@angular/material-moment-adapter": "^8.2.3",
"@angular/platform-browser": "^8.2.2",
"@angular/platform-browser-dynamic": "^8.2.2",
"@angular/router": "^8.2.2",
"@asymmetrik/ngx-leaflet": "3.0.1",
"@fortawesome/angular-fontawesome": "^0.5.0",
"@fortawesome/fontawesome-free": "^5.11.2",
"@fortawesome/fontawesome-svg-core": "^1.2.25",
"@fortawesome/free-solid-svg-icons": "^5.11.2",
"@fullcalendar/angular": "^4.4.2",
"@fullcalendar/core": "^4.4.2",
"@fullcalendar/daygrid": "^4.4.2",
"@fullcalendar/interaction": "^4.4.2",
"@fullcalendar/list": "^4.4.2",
"@fullcalendar/timegrid": "^4.4.2",
"@kolkov/angular-editor": "^1.1.4",
"@nebular/auth": "^4.2.2",
"@nebular/eva-icons": "^4.2.2",
"@nebular/security": "^4.2.2",
"@nebular/theme": "^4.2.2",
"@ng-bootstrap/ng-bootstrap": "^5.1.0",
"@rosen-group/ngx-onboarding": "^1.3.0",
"@swimlane/ngx-charts": "^10.0.0",
"@syncfusion/ej2-angular-charts": "^18.3.35",
"@syncfusion/ej2-angular-richtexteditor": "^17.2.41",
"@types/quill": "^2.0.2",
"@types/socket.io-client": "^1.4.32",
"@types/web-animations-js": "^2.2.8",
"@vimeo/player": "^2.12.2",
"angular-calendar": "^0.27.18",
"angular-star-rating": "^4.0.0-beta.3",
"angular-tree-component": "7.2.0",
"angular2-chartjs": "0.4.1",
"angular2-toaster": "^7.0.0",
"bootstrap": "4.3.1",
"chart.js": "2.7.1",
"ckeditor": "4.7.3",
"classlist.js": "1.1.20150312",
"core-js": "2.5.1",
"css-star-rating": "^1.2.4",
"date-fns": "^1.30.1",
"echarts": "^4.0.2",
"error-stack-parser": "^2.0.3",
"eva-icons": "^1.1.0",
"file-saver": "^2.0.2",
"hammerjs": "^2.0.8",
"html2canvas": "^1.0.0-rc.7",
"i": "^0.3.6",
"igniteui-angular": "^8.1.3",
"increase-memory-limit": "^1.0.7",
"intl": "1.2.5",
"ionicons": "2.0.1",
"leaflet": "1.2.0",
"marked": "^0.7.0",
"mat-video": "^2.8.1",
"moment-es6": "^1.0.0",
"nebular-icons": "1.1.0",
"ng-animate": "^0.3.4",
"ng-zorro-antd": "^11.2.0",
"ng2-charts": "^2.3.3",
"ng2-ckeditor": "^1.2.4",
"ng2-completer": "2.0.8",
"ng2-pdf-viewer": "^5.3.3",
"ng2-pdfjs-viewer": "^5.0.1",
"ng2-search-filter": "^0.5.1",
"ng2-smart-table": "^1.5.0",
"ngp-sort-pipe": "0.0.4",
"ngx-bootstrap": "^5.6.2",
"ngx-echarts": "^4.0.1",
"ngx-editor": "^4.1.0",
"ngx-embed-video": "^1.0.4",
"ngx-extended-pdf-viewer": "^1.6.2",
"ngx-material-timepicker": "^4.0.2",
"ngx-pagination": "^4.1.0",
"ngx-quicklink": "^0.2.0",
"ngx-show-hide-password": "^2.1.0",
"ngx-youtube-player": "^7.1.1",
"node-sass": "^4.12.0",
"normalize.css": "6.0.0",
"npm": "^6.10.3",
"pace-js": "1.0.2",
"primeicons": "^2.0.0",
"primeng": "^8.0.2",
"quill": "^1.3.6",
"roboto-fontface": "0.8.0",
"rxjs": "6.5.2",
"rxjs-compat": "6.3.0",
"socicon": "3.0.5",
"stacktrace-js": "^2.0.0",
"tinymce": "4.5.7",
"tslib": "^1.9.0",
"typeface-exo": "0.0.22",
"web-animations-js": "github:angular/web-animations-js#release_pr208",
"xlsx": "^0.15.4",
"zone.js": "~0.9.1"
,
"devDependencies":
"@angular-devkit/build-angular": "~0.800.2",
"@angular/cli": "^8.2.2",
"@angular/compiler-cli": "^8.2.2",
"@angular/language-service": "8.0.0",
"@compodoc/compodoc": "1.0.1",
"@types/d3-color": "1.0.5",
"@types/googlemaps": "^3.37.4",
"@types/jasmine": "2.5.54",
"@types/jasminewd2": "2.0.3",
"@types/leaflet": "1.2.3",
"@types/node": "6.0.90",
"codelyzer": "^5.0.1",
"conventional-changelog-cli": "1.3.4",
"husky": "0.13.3",
"jasmine-core": "2.6.4",
"jasmine-spec-reporter": "4.1.1",
"jquery": "^3.4.1",
"karma": "1.7.1",
"karma-chrome-launcher": "2.1.1",
"karma-cli": "1.0.1",
"karma-coverage-istanbul-reporter": "1.3.0",
"karma-jasmine": "1.1.0",
"karma-jasmine-html-reporter": "0.2.2",
"npm-run-all": "4.0.2",
"protractor": "5.1.2",
"rimraf": "2.6.1",
"stylelint": "7.13.0",
"ts-node": "3.2.2",
"tslint": "^5.7.0",
"tslint-language-service": "^0.9.9",
"typescript": "3.4.5"
【问题讨论】:
抱歉,这里只发布错误消息是不够的。你想表达什么? 当我使用 ng serve 运行时出现这些错误 你运行npm install
了吗?错误消息告诉我,ngx-bootstrap
丢失了。
@Lynx242 是的,我已经运行了 npm install
请提供您的 package.json
【参考方案1】:
您可以跳过库检查(这不一定是个好主意,但它很可能会解决您当前的问题):
"compilerOptions":
"skipLibCheck": true,
,
(这是在tsconfig.json
-文件中完成的)
可以在 *** 问题中找到有关此功能的更多信息:Usage of the TypeScript compiler argument 'skipLibCheck'
【讨论】:
以上是关于错误 TS1086:无法在环境上下文中声明访问器的主要内容,如果未能解决你的问题,请参考以下文章
错误 TS1086 无法在环境上下文中声明访问器。获取 firebaseUiConfig(): NativeFirebaseUIAuthConfig
错误 ngx-daterangepicker-material 无法在环境上下文中声明访问器
angular中安装@angular/cdk时遇到的错误——node_modules/@angular/cdk/table/table.d.ts:277:9 - error TS1086: An ac
angular中安装@angular/cdk时遇到的错误——node_modules/@angular/cdk/table/table.d.ts:277:9 - error TS1086: An ac