ngx-cookie: Could not resolve @nguniversal/express-engine/token
I’m submitting a … (check one with “x”)
[ X] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request
Current behavior Version 4.1.1 breaks when building angular project.
ERROR in ../ngx-cookie/ngx-cookie.ts(10,23): Error during template compile of 'CookieBackendService'
Could not resolve @nguniversal/express-engine/tokens relative to [object Object]..
Reproduction of the problem
Install the lastest package (4.1.1) and ng serve or ng build
Please tell us about your environment:
-
ngx-cookie version: 4.1.1
-
Angular version: 7.0.3
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 54
- Comments: 20 (1 by maintainers)
Same, it should be included in
package.jsonas a dependency but it is not.workaround => add it to your project:
npm i @nguniversal/express-engine -Din my case, I downgraded dependency to version v4.0.2, working now.
Especially frustrating when you don’t even use server side rendering!
Same error with latest versions:
7.1.47.1.40.11.44.1.2However, it works after:
npm install @nguniversal/express-engine --saveDevthank you to @shprinkit needs ‘npm install @nguniversal/express-engine’, however anyone with obsessive-compulsive disorder don’t want to install this。
Angular CLI:
I’m not sure what the changes you made to ask this, I see it is in
package.jsonas a dependency but it is maybe the build itself broken? I see it inpeerDependenciesin published version but independenciesin the source file.And I’m using version 4.1.2!
Edit: Oh I see it is commit 1956eff to blame.
Agree. One year has passed since ticked was opened and problem still exists:
ngx-cookie: 4.1.2. The quality of JavaScript packets are amazing…Still an issue, I don’t see why this should be mandatory dependency.
any update about this issue?
Fixed.
@MarkoSulamagi I had
^4.0.2in package.json, all working fine for me (if Irm -rf node_modules && npm install) BUT on someone else’s computer (same os, same node & npm versions), cloning the project for the first time, the error appeared. I don’t know why, maybe npm cache? Haven’t triednpm cithough. Anyway, the solution that actually permitted me to still sleep at night was replacing^4.0.2with4.0.2in package.json 😁 as I knew that it was working fine when I created the project with 4.0.2. Didn’t invest any time in checking in what version it broke.@almothafar in my experience, most apps have/need authorization. In order to properly render a protected route on the server (or even an unprotected route that still needs to display some data about the current user), you need that token or whatever you store for authorization. And since we don’t have localStorage on the server, that being a client-side only mechanism, the only way I see is to use cookies to store stuff like a token, because you need to read and use that token in your request headers while rendering server side as well, not just from the browser. That being said, I ended up writing my own cookie service long ago, since it’s not that hard to do.