ReferenceError: document is not defined
at getAll (D:\demo\node_modules\es-cookie\src\es-cookie.js:61:18)
at Object.get (D:\demo\node_modules\es-cookie\src\es-cookie.js:65:12)
at new l (D:\demo\dist-server\main.bundle.js:1:396956)
at _createClass (D:\demo\node_modules\@angular\core\bundles\core.umd.js:10969:20)
at _createProviderInstance$1 (D:\demo\node_modules\@angular\core\bundles\core.umd.js:10933:26)
at resolveNgModuleDep (D:\demo\nodemodules\@angular\core\bundles\core.umd.js:10918:17)
at NgModuleRef.get (D:\demo\node_modules\@angular\core\bundles\core.umd.js:12150:16)
at resolveDep (D:\demo\node_modules\@angular\core\bundles\core.umd.js:12648:45)
at createClass (D:\demo\node_modules\@angular\core\bundles\core.umd.js:12518:32)
at createDirectiveInstance (D:\demo\node_modules\@angular\core\bundles\core.umd.js:12355:37)
import {set as setCookie, get as getCookie, remove as removeCookie} from 'es-cookie';
This library is intended for browser usage, not server-side rendering. If you want to read a cookie on the server (where document.cookie doesn't exist), you will need to access it via the HTTP header instead.
ReferenceError: document is not defined at getAll (D:\demo\node_modules\es-cookie\src\es-cookie.js:61:18) at Object.get (D:\demo\node_modules\es-cookie\src\es-cookie.js:65:12) at new l (D:\demo\dist-server\main.bundle.js:1:396956) at _createClass (D:\demo\node_modules\@angular\core\bundles\core.umd.js:10969:20) at _createProviderInstance$1 (D:\demo\node_modules\@angular\core\bundles\core.umd.js:10933:26) at resolveNgModuleDep (D:\demo\nodemodules\@angular\core\bundles\core.umd.js:10918:17) at NgModuleRef.get (D:\demo\node_modules\@angular\core\bundles\core.umd.js:12150:16) at resolveDep (D:\demo\node_modules\@angular\core\bundles\core.umd.js:12648:45) at createClass (D:\demo\node_modules\@angular\core\bundles\core.umd.js:12518:32) at createDirectiveInstance (D:\demo\node_modules\@angular\core\bundles\core.umd.js:12355:37)
import {set as setCookie, get as getCookie, remove as removeCookie} from 'es-cookie';
user_details: any;
setCookie('user_details', JSON.stringify(this.user_details));
this.user_details = getCookie('user_details'); if(this.user_details){ this.user_details = JSON.parse(getCookie('user_details')); }
AND try it but not work this.user_details = JSON.parse(getCookie('user_details'));
package.json
{ "name": "demo", "version": "0.0.0", "license": "MIT", "scripts": { "ng": "ng", "start": "npm run build && npm run server", "build": "ng build --prod && ng build --prod --app universal --output-hashing=none", "test": "echo \"Error: no test... minimal project\" && exit 1", "lint": "echo \"Error: no lint... minimal project\" && exit 1", "e2e": "echo \"Error: no e2e... minimal project\" && exit 1", "server": "node server.js" }, "private": true, "dependencies": { "@angular/animations": "^5.1.0", "@angular/common": "^5.1.0", "@angular/compiler": "^5.1.0", "@angular/core": "^5.1.0", "@angular/forms": "^5.1.0", "@angular/http": "^5.1.0", "@angular/platform-browser": "^5.1.0", "@angular/platform-browser-dynamic": "^5.1.0", "@angular/platform-server": "^5.1.0", "@angular/router": "^5.1.0", "@ng-bootstrap/ng-bootstrap": "^1.0.0-beta.7", "@nguniversal/express-engine": "^5.0.0-beta.5", "@ngx-utils/cookies": "^2.0.2", "angular-font-awesome": "^3.0.3", "angular-pipes": "^6.5.3", "angular2-cookie": "^1.2.6", "angular2-cookies": "^0.1.0", "angular2-cool-storage": "^3.1.3", "angular2-image-zoom": "^1.2.1", "angular2-useful-swiper": "^5.0.1", "bootstrap": "^3.3.7", "cookie-parser": "^1.4.3", "core-js": "^2.5.2", "es-cookie": "^1.1.1", "express": "^4.16.2", "font-awesome": "^4.7.0", "hammerjs": "^2.0.8", "jquery": "^3.2.1", "ngx-carousel": "^1.3.5", "ngx-cookie": "^2.0.1", "ngx-cookie-service": "^1.0.9", "ngx-infinite-scroll": "^0.7.2", "ngx-metadata": "^4.0.3", "ngx-pipes": "^2.0.5", "ngx-swiper-wrapper": "^5.0.5", "roboto-fontface": "^0.8.0", "rxjs": "^5.5.5", "swiper": "^3.4.2", "zone.js": "^0.8.18" }, "devDependencies": { "@angular/cli": "1.6.0", "@angular/compiler-cli": "^5.1.0", "@angular/language-service": "^5.1.0", "@types/jasmine": "~2.8.2", "@types/jasminewd2": "~2.0.3", "@types/node": "~8.0.57", "codelyzer": "~4.0.2", "jasmine-core": "~2.8.0", "jasmine-spec-reporter": "~4.2.1", "karma": "~1.7.1", "karma-chrome-launcher": "~2.2.0", "karma-cli": "~1.0.1", "karma-coverage-istanbul-reporter": "^1.3.0", "karma-jasmine": "~1.1.1", "karma-jasmine-html-reporter": "^0.2.2", "protractor": "~5.2.1", "ts-node": "~4.0.1", "tslint": "~5.8.0", "typescript": "~2.4.2", "webpack": "^3.10.0" } }