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 ;-)