Angular 11 Module '"Ngx-Mask"' Has No Exported Member 'Ngxmaskmodule'
I Am Running Angular 11. I Have Not Taken Any Action Relating to Updating Angular Versions; I Only Installed One New Package Which Is Not Working. I Ran Npm I...
I am running Angular 11. I have not taken any action relating to updating Angular versions; I only installed one new package which is not working.
I ran npm i --save ngx-mask and it successfully installed version 15.0.2 (latest as of now), which I can verify in my package.json file.
I attempted to import the module using the following. I tried this in app.module.ts as well as in the module.ts file of the component.
import {NgxMaskModule,IConfig} from 'ngx-mask'
export const options: Partial<IConfig> | (() => Partial<IConfig>) = null;
@NgModule({
(...)
imports: [
NgxMaskModule.forRoot(options)
]
(...)
})
I am getting this error for the NgxMaskModule import
Module '"ngx-mask"' has no exported member 'NgxMaskModule'
And this error for the NgxMaskModule.forRoot(options) line in the Imports:
Value at position 55 in the NgModule.imports of AppModule is not a reference
Value could not be determined statically.(-991010)
app.module.ts(248, 5): Unable to evaluate this expression statically.
app.module.ts(248, 5): Unknown reference.
What am I doing wrong? What do I need to do in order to use ngx-mask?
3 Answers
try install new version:
npm i [email protected]
next step import using directory:
import { NgxMaskModule} from 'ngx-mask/lib/ngx-mask.module';
After quickly scanning through the documentation I'm afraid you're using the wrong approach to start using the ngx-mask package. As you said you installed version 15.0.2, but you're using the approach which is meant for versions < 15.0.0. The following URL to the documentation should help you to get up and running with ngx-mask version 15.0.2: link
Obviously, if you want to use your current approach, you can always downgrade the version of your ngx-mask package.
for those who are on angular 15 use version 14.2.4, it worked for me
run: npm install --save [email protected]
in app.module.ts:
import { NgxMaskModule } from 'ngx-mask';
in the imports add:
imports: [ NgxMaskModule.forRoot(),