admin管理员组文章数量:1430480
I installed ng-select2 package. And I'm getting this error and code is not able to plie after 'ng serve'.
- node version is 8.10.0
- npm version 6.0.0
- List item
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-select2ponent.ts (188,18): Cannot find name 'Select2Options'.
ERROR in /src/app/pages/dashboard/dashboardponent.ts (91,19): Cannot find name 'Select2Options'.
// Dashboard ponent ts(91, 19) error + I've also added import to it:
public options: Select2Options;
Solutions I tried are:
- As per documentation, added import and also imported in @NgModule to app.module.ts
- I've [email protected] and @types/[email protected] installed as well.
- npm cache verify, then npm cache clean --force and updated npm
- deleted package-lock.json and then ran npm install But this doesn't seem to work.
I installed ng-select2 package. And I'm getting this error and code is not able to plie after 'ng serve'.
- node version is 8.10.0
- npm version 6.0.0
- List item
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.ponent.ts (188,18): Cannot find name 'Select2Options'.
ERROR in /src/app/pages/dashboard/dashboard.ponent.ts (91,19): Cannot find name 'Select2Options'.
// Dashboard ponent ts(91, 19) error + I've also added import to it:
public options: Select2Options;
Solutions I tried are:
- As per documentation, added import and also imported in @NgModule to app.module.ts
- I've [email protected] and @types/[email protected] installed as well.
- npm cache verify, then npm cache clean --force and updated npm
- deleted package-lock.json and then ran npm install But this doesn't seem to work.
2 Answers
Reset to default 5As stated in the github issue: The interface Select2Options is removed/renamed to Options in the latest version 4.0.45
To resolve this issue, I simply downgrade the package to 4.0.44 by running npm install @ types/[email protected] --save and this worked for me.
https://github./NejcZdovc/ng2-select2/issues/124
I had a similar problem. I installed according to the selected2 documentation. Unfortunately, an error appeared
Error: src/app/app.module.ts:6:33 - error TS2307: Cannot find module './select2' or its corresponding type declarations. 6 import { NgSelect2Module } from './select2';
Although it was in the Initial Chunk Files
Initial Chunk Files | Names
select2.js | select2
I tried your solution but the piler said it is not a module.
Error: src/app/app.module.ts:6:33 - error TS2306: File 'C:/Users/admin/Documents/WorkspaceAngular/medical-v0.9/node_modules/@types/select2/index.d.ts' is not a module.
6 import { NgSelect2Module } from '@types/select2',
So I installed ponenet npm i ng-select2-ponent --save
https://www.npmjs./package/ng-select2-ponent
It worked ;-)
本文标签: javascriptAngular (413) ngselect2 ErrorStack Overflow
版权声明:本文标题:javascript - Angular (4.1.3) ng-select2 Error - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745444925a2658620.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论