1

In Angular (ver 10.2) I'm trying to use ngx-cookie-service per instructions:

  1. Ran "npm install ngx-cookie-service --save"
  2. In app.module.ts, added provider as follows: "providers: [CookieService],"
  3. In app.module.ts, imported as follows: "import { CookieService } from 'ngx-cookie-service/lib/cookie.service';"

I can use it in the code & no errors shown in any file, so it seems it finds it... but when trying to build "ng build --prod", I get this error:

ERROR in ./src/app/app.module.ts Module not found: Error: Can't resolve 'ngx-cookie-service/lib/cookie.service'

Any ideas?

Pavan Jadda
  • 4,306
  • 9
  • 47
  • 79
Ben
  • 495
  • 1
  • 7
  • 17

1 Answers1

1

From what I see the import that you are using is incorrect. It should be:

import { CookieService } from 'ngx-cookie-service';

And you can check it out inside the library readme.

You've probably copied the code from a demo project inside the library itself and that's why it's not working or maybe the text editor auto generated it, sometimes it happens.

Inside the ngx-cookie-service project it will work because the library is local but in your case it's an external package so you will need to use the public_api.

user1
  • 1,035
  • 1
  • 9
  • 17