javascript - 在我的应用程序 angular2 aspnet core 中找不到错误 angular2-cookies/core.js

标签 javascript node.js angular cookies systemjs

我搜索了大约 2 个小时,我的错误在哪里。 这就是原因,我尝试在这里提出我的问题。 我有这个错误:

"angular2-cookies/core.js not found"

我已经使用 npm 正确安装了 angular2-cookie。

这是我的 ServiceCookie:

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);
    }
}

这是我的 system.config.js,我在其中声明了用于运行我的应用程序的路径文件。

 /**
 * 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);

最佳答案

我在你的 system.config.js 中发现的一个拼写错误应该是

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

而不是

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

在您的 map 中{},不确定这是否能完全解决问题。

关于javascript - 在我的应用程序 angular2 aspnet core 中找不到错误 angular2-cookies/core.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37751303/

相关文章:

javascript - 如何在加载我的网站主体之前预加载我所有的 javascript 文件?

Javascript,如何用点分割键来恢复json结构

javascript - 在 Polymer 2.x 中设置原生输入的样式?

node.js - nodejs - 在 for 循环结束后返回 Promise

angular2 构建问题 useFactory 与功能

angular - 如何在 Angular 2 应用程序中显示 SSRS 报告

javascript - 我收到错误列表中的每个 child 都应该有一个唯一的 "key" Prop

javascript - 我可以使用 node.js、angular 和 sequelize 构建移动应用程序吗?

node.js - 无法读取火炮脚本文件中的 CSV 文件

angular - 在Angular中导入模块时如何从模块自动运行服务?