Javascript 角度5 ng自举类型';ElementRef';不是一般的错误
我在这些版本中使用angular 5和ng引导:Javascript 角度5 ng自举类型';ElementRef';不是一般的错误,javascript,node.js,angular,angular5,ng-bootstrap,Javascript,Node.js,Angular,Angular5,Ng Bootstrap,我在这些版本中使用angular 5和ng引导: "private": true, "dependencies": { "@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
"private": true,
"dependencies": {
"@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/router": "^5.2.0",
"@ng-bootstrap/ng-bootstrap": "^2.1.0",
"angular-in-memory-web-api": "^0.5.4",
"angular2-moment": "^1.9.0",
"bootstrap": "^4.1.1",
"core-js": "^2.4.1",
"date-util": "^1.2.1",
"material-icons": "^0.2.1",
"ngx-bootstrap": "^3.0.0",
"normalize.css": "^8.0.0",
"rxjs": "^5.5.6",
"zone.js": "^0.8.19"
},
当我得到ng serve时,出现以下错误:
**
未能编译
node_modules/@ng bootstrap/ng bootstrap/buttons/radio.d.ts(58,96):
错误TS2315:类型“ElementRef”不是泛型。
node_modules/@ng bootstrap/ng bootstrap/datepicker/datepicker input.d.ts(121,67):
错误TS2315:类型“ElementRef”不是泛型。
node_modules/@ng bootstrap/ng bootstrap/datepicker/datepicker.d.ts(115208):
错误TS2315:类型“ElementRef”不是泛型。
node_modules/@ng bootstrap/ng bootstrap/dropdown/dropdown.d.ts(12,45):
错误TS2315:类型“ElementRef”不是泛型。
node_modules/@ng bootstrap/ng bootstrap/dropdown/dropdown.d.ts(29,45):
错误TS2315:类型“ElementRef”不是泛型。
node_modules/@ng bootstrap/ng bootstrap/dropdown/dropdown.d.ts(37,44):
错误TS2315:类型“ElementRef”不是泛型。
node_modules/@ng bootstrap/ng bootstrap/modal/modal window.d.ts(13,40):
错误TS2315:类型“ElementRef”不是泛型
我突然面临同样的问题 在我的例子中,我使用的是ng boostrasp 2.0.0,但我是这样指定依赖项的:
"@ng-bootstrap/ng-bootstrap": "^2.0.0"
它在某个时间点(基于过去成功构建的日志:从6月1日起的某个地方)开始采用2.1.0版
因此,我更改了我的package.json,选择了2.0.0:
"@ng-bootstrap/ng-bootstrap": "2.0.0"
这解决了我的问题。将ng引导版本更改为“2.0.0”
“@ng bootstrap/ng bootstrap”:“2.0.0”
然后npm安装
&尝试为应用程序提供服务
我面临同样的问题,上述方法对我有效。我也有同样的问题。因此,我取消安装了
ng引导程序
然后我直接用2.0.0
版本重新安装它
npm安装--save@ng bootstrap/ng-bootstrap@2.0.0
您需要在ng引导>=2.0.0的情况下使用Angular 6.0.0或更高版本。npm/纱线安装应在安装期间向您发出警告
恢复到ng bootstrap 2.0.0不是一个解决方案,因为您只需使用此版本的库,并且不会收到更新/修复
要正确解决此问题,您需要:
- 将Angular升级到6.0.0或更高版本(推荐)
- 使用与Angular 5.x(1.1.2)兼容的最新ng引导
npm install --save @ng-bootstrap/ng-bootstrap@2.0.0
帮助。安装ng引导程序,检查版本兼容性
ng-bootstrap Angular Bootstrap CSS
1.x.x 5.0.2 4.0.0
2.x.x 6.0.0 4.0.0
3.x.x 6.1.0 4.0.0
4.x.x 7.0.0 4.0.0
5.x.x 8.0.0 4.3.1
您可以在此处的“版本”选项卡下找到版本详细信息,
您使用哪个版本的Typescript?最新版本是2.9.1。只是为了清楚起见;要卸载的确切命令是:npm uninstall@ng bootstrap/ng bootstrap。顺便说一句,请注意,安装程序仍然会警告angular版本,但安装后它确实可以工作。对于angular 5,我建议使用以下命令:npm install--save@ng bootstrap/ng-bootstrap@2.0.0