angular - node_modules/xterm/typings/xterm.d.ts(10,1) : error TS1084: Invalid 'reference' directive syntax 中出现错误

标签 angular typescript angular5 xtermjs

我在 Angular5 中使用 xterm。但它在运行时抛出错误。

当我运行 ngserve 时,它会抛出这样的错误

node_modules/xterm/typings/xterm.d.ts(10,1) 中出现错误:错误 TS1084:“引用”指令语法无效

这是我的package.json 文件

 `{
  "name": "paper-dashboard-pro-angular",
  "version": "1.1.0",
  "repository": {
  "type": "git",
  "url": "https://github.com/creativetimofficial/ct-paper-dashboard-pro- 
   angular.git"
  },
   "scripts": {
   "ng": "ng",
   "start": "ng serve",
   "build": "ng build",
   "test": "ng test",
   "lint": "ng lint",
   "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
  "@adactive/bootstrap-tagsinput": "0.8.2",
  "@agm/core": "1.0.0-beta.2",
  "@angular/animations": "^5.2.0",
  "@angular/common": "^5.2.0",
  "@angular/compiler": "^5.2.0",
  "@angular/core": "^5.2.0",
  "@angular/forms": "^5.2.0",
  "@angular/http": "^5.2.0",
  "@angular/platform-browser": "^5.2.0",
  "@angular/platform-browser-dynamic": "^5.2.0",
  "@angular/platform-server": "^5.2.0",
  "@angular/router": "^5.2.0",
  "@ng-bootstrap/ng-bootstrap": "^2.1.0",
  "@ngui/map": "0.30.3",
  "@types/googlemaps": "3.26.14",
  "ajv": "6.5.0",
  "bencode": "^2.0.0",
  "bootstrap": "4.1.0",
  "bootstrap-notify": "3.1.3",
  "bootstrap-select": "1.12.4",
  "bootstrap-tagsinput": "0.7.1",
  "chart.js": "2.7.2",
  "chartist": "0.11.0",
  "chartist-plugin-zoom": "0.4.0",
  "chartjs-plugin-zoom": "0.5.0",
  "core-js": "2.4.1",
  "datatables": "1.10.12",
  "datatables.net": "^1.10.19",
  "datatables.net-bs": "1.10.12",
  "datatables.net-bs4": "^1.10.19",
  "datatables.net-colreorder": "^1.5.1",
  "datatables.net-colreorder-bs4": "^1.5.1",
  "datatables.net-fixedcolumns": "^3.2.6",
  "datatables.net-fixedcolumns-bs4": "^3.2.6",
  "datatables.net-fixedheader-bs4": "^3.1.5",
  "datatables.net-responsive": "2.1.1",
  "datatables.net-responsive-bs4": "^2.2.3",
  "datatables.net-rowgroup-bs4": "^1.0.3",
  "datatables.net-scroller-bs4": "^1.5.1",
  "datatables.net-select-bs4": "^1.2.7",
  "easy-pie-chart": "2.1.7",
  "eonasdan-bootstrap-datetimepicker": "4.17.47",
  "fullcalendar": "3.4.0",
  "jasny-bootstrap": "3.1.3",
  "jquery": "3.2.1",
  "jvectormap": "2.0.4",
  "jw-bootstrap-switch-ng2": "1.0.10",
  "ngx-chips": "^1.9.2",
  "nouislider": "9.2.0",
  "perfect-scrollbar": "^1.4.0",
  "popper.js": "1.14.1",
  "rxjs": "^5.5.2",
  "rxjs-compat": "6.1.0",
  "sweetalert2": "7.22.0",
  "text-encoding": "^0.7.0",
  "twitter-bootstrap-wizard": "1.2.0",
  "web-animations-js": "2.3.1",
  "xterm": "^3.10.1",
  "zone.js": "0.8.26"
 },
 "devDependencies": {
"@angular-devkit/build-angular": "0.6.3",
"@angular/cli": "6.0.3",
"@angular/compiler-cli": "^5.2.0",
"@types/bootstrap": "3.3.32",
"@types/chartist": "0.9.34",
"@types/jasmine": "2.5.38",
"@types/jquery": "1.10.31",
"@types/node": "6.0.73",
"codelyzer": "4.3.0",
"jasmine-core": "2.5.2",
"jasmine-spec-reporter": "3.2.0",
"karma": "2.0.2",
"karma-chrome-launcher": "2.0.0",
"karma-cli": "1.0.1",
"karma-coverage-istanbul-reporter": "0.2.0",
"karma-jasmine": "1.1.0",
"karma-jasmine-html-reporter": "0.2.2",
"protractor": "5.3.2",
"ts-node": "2.0.0",
"tslint": "5.9.1",
"typescript": "^2.5.3"
 }
}

这样运行时会抛出错误

node_modules/xterm/typings/xterm.d.ts(10,1) 中出现错误:错误 TS1084:“引用”指令语法无效

如何解决?

最佳答案

您可以使用最新版本的 typescript 吗?

如果您有能力升级 typescript,请尝试使用 typescript 3.x 版本来解决此问题。

注意:我在尝试集成xterm js时也面临同样的问题。升级 typescript 版本后,这个问题得到了解决。

引用: See here

关于angular - node_modules/xterm/typings/xterm.d.ts(10,1) : error TS1084: Invalid 'reference' directive syntax 中出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54416065/

相关文章:

javascript - 如何获取 Angular 4 项目构建中包含的 .json 文件?

javascript - 括号中的点用于访问嵌套属性

angular - 从组件类访问模板引用变量

javascript - 使用ngx-print打印图像的问题

angularjs - 无法使用 angular-cli 创建 Angular 5 项目

css - 如何在没有单选按钮的情况下制作垫单选组?

angular - 以 Angular 2 react 形式动态删除表单控件

Angular 7 - 服务 worker 未注册

javascript - TypeScript 错误 : "Type ' number' is not assignable to type '0 | 1 | 2' ". 为什么会出现此错误?

angular - ngIf- 表达式在检查后发生了变化。先前值 : 'ngIf: false' . 当前值: 'ngIf: true'