Yvan
Yvan

Reputation: 1121

Error angular2-cookies/core.js not found in my app angular2 aspnet core

I search around 2hours where is my error. That is the reason, I try to ask my question here. I have this error :

"angular2-cookies/core.js not found"

I have installed angular2-cookie correctly with npm.

Here is my ServiceCookies :

import { Injectable } from '@angular/core';
import {CookieService, CookieOptionsArgs} from 'angular2-cookie/core';

@Injectable()
export class CookiesService {
    private option: CookieOptionsArgs;

    constructor(private cookieService: CookieService) {
    }

    getCookie(key: string) {
        return this.cookieService.get('cookieName');
    }

    setCookie(key: string, value: string) {
        var expiresDate = new Date(new Date().getTime() + 3600 * 1000);
        this.option.expires = expiresDate.toDateString();
        // 10 ans pour le moment 
        this.cookieService.put(key, value, this.option.expires);
    }

    deleteCookie(key: string) {
        this.cookieService.remove(key);
    }
}

Here is my system.config.js where i declare paths files for the running of my app.

 /**
 * System configuration for Angular 2 samples
 * Adjust as necessary for your application needs.
 * Override at the last minute with global.filterSystemConfig (as plunkers do)
 */
(function (global) {

    // map tells the System loader where to look for things
    var map = {
        'app': 'app', // 'dist',
        'rxjs': 'js/rxjs',
        '@angular': 'js/@angular',
        'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api',
        'angular2-cookie': 'node_modules/angular2-cookies'
    };

    // packages tells the System loader how to load when no filename and/or no extension
    var packages = {
        'app': { main: 'boot.js', defaultExtension: 'js' },
        'rxjs': { defaultExtension: 'js' },
        'angular2-in-memory-web-api': { defaultExtension: 'js' },
                'angular2-cookie': { main: 'core.js', defaultExtension: 'js' }
    };

    var packageNames = [
      '@angular/common',
      '@angular/compiler',
      '@angular/core',
      '@angular/http',
      '@angular/platform-browser',
      '@angular/platform-browser-dynamic',
      '@angular/router-deprecated',
      '@angular/router',
      '@angular/testing',
      '@angular/upgrade'
    ];

    var paths = {
        'node_modules': 'node_modules',
        'app': 'app/',
        'app/*': 'app/*'
    };

    // add package entries for angular packages in the form '@angular/common': { main: 'index.js', defaultExtension: 'js' }
    packageNames.forEach(function (pkgName) {
        packages[pkgName] = { main: 'index.js', defaultExtension: 'js' };
    });

    var config = {
        map: map,
        packages: packages,
        paths: paths
    }

    if (global.filterSystemConfig) { global.filterSystemConfig(config); }

    System.config(config);

})(this);

Upvotes: 0

Views: 506

Answers (1)

Cwebster
Cwebster

Reputation: 26

One typo I've found in your system.config.js is that is should be

'angular2-cookie': 'node_modules/angular2-cookie'

and not

'angular2-cookie': 'node_modules/angular2-cookies'

in your map{}, not sure if that will fix it completely.

Upvotes: 1

Related Questions