Angular JS ngx-toastr Error: Module not found: Error: Package path ./public_api is not exported from package

2k views Asked by At

./src/app/nav/nav.component.ts:5:0-44 - Error: Module not found: Error: Package path ./public_api is not exported from package C:\Users\Score\demo\DatingApp\client\node_modules\ngx-toastr (see exports field in C:\Users\Score\demo\DatingApp\client\node_modules\ngx-toastr\package.json)

./src/app/register/register.component.ts:4:0-55 - Error: Module not found: Error: Package path ./toastr/toastr.service is not exported from package C:\Users\Score\demo\DatingApp\client\node_modules\ngx-toastr (see exports field in C:\Users\Score\demo\DatingApp\client\node_modules\ngx-toastr\package.json) [1]: https://i.stack.imgur.com/WaZNB.png

3

There are 3 answers

0
Ajinkya H Jagadale On

import toastService in your service file like this:

import { ToastrService } from 'ngx-toastr';

0
Monirul Islam On

Use this

import { ToastrService } from 'ngx-toastr';

Instade of

import { ToastrService } from 'ngx-toastr/public_api';
import { ToastrService } from 'ngx-toastr/toastr/toastr.service';

0
kalmur On

I had the same problem. I uninstalled the version I had and instead, I used this command to install the older version:

npm i [email protected]

Hope that solves it for you!