Angular(4.1.3)ng-select2错误

时间:2018-05-08 07:48:30

标签: javascript node.js angular npm

我安装了ng-select2 package。我收到此错误,代码无法在'ng serve'之后编译。

  • 节点版本为8.10.0
  • npm version 6.0.0
  • 列表项

OS Windows 7

ERROR in d:/PATH-TO-PROJECT-FOLDER/node_modules/@types/select2/index.d.ts (233,49): 'JQuery' only refers to a type, but is being used as a namespace here.

ERROR in D:/PATH-TO-PROJECT-FOLDER/node_modules/ng-select2/ng-select2/ng-select2.component.ts (188,18): Cannot find name 'Select2Options'.

ERROR in /src/app/pages/dashboard/dashboard.component.ts (91,19): Cannot find name 'Select2Options'.

// Dashboard component ts(91, 19) error + I've also added import to it:
public options: Select2Options;

我尝试的解决方案是:

  • 根据文档,添加导入并在@NgModule中导入到app.module.ts
  • 我也安装了jquery@3.2.1和@ types / jquery @ 2.0.41。
  • npm cache verify,然后npm cache clean --force并更新npm
  • 删除了package-lock.json,然后运行npm install 但这似乎不起作用。

1 个答案:

答案 0 :(得分:3)

正如github问题所述: SelectExptions界面被删除/重命名为最新版本4.0.45中的选项

要解决此问题,我只需通过运行将软件包降级到4.0.44 npm install @ types/select2@4.0.44 --save,这对我有用。

https://github.com/NejcZdovc/ng2-select2/issues/124