如何在Angular 5中配置ngx-cookie-service

时间:2018-06-01 04:35:36

标签: cookies angular5

我在项目的根模块中安装了ngx-cookie-service

npm i --save ngx-cookie-service

并在app.module

中导入如下
import { CookieService } from "ngx-cookie-service";

@NgModule({
    imports: [BrowserModule, AppRoutingModule, BrowserAnimationsModule],
    declarations: [AppComponent], 
    providers: [CookieService],
    bootstrap: [AppComponent]
})
export class AppModule { }

和systemjs.config如下:

    'ngx-cookie-service': 'npm:ngx-cookie-service/cookie-service/cookie.service.js'

我收到以下错误

(SystemJS) XHR error (403) loading https://127.0.0.1:470/node_modules/ngx-cookie-service/cookie-service
    Error: XHR error (403) loading https://127.0.0.1:470/node_modules/ngx-cookie-service/cookie-service
        at XMLHttpRequest.wrapFn (https://127.0.0.1:470/node_modules/zone.js/dist/zone.js:1166:39)
        at ZoneDelegate.invokeTask (https://127.0.0.1:470/node_modules/zone.js/dist/zone.js:421:31)
        at Zone.runTask (https://127.0.0.1:470/node_modules/zone.js/dist/zone.js:188:47)
        at ZoneTask.invokeTask [as invoke] (https://127.0.0.1:470/node_modules/zone.js/dist/zone.js:496:34)
        at invokeTask (https://127.0.0.1:470/node_modules/zone.js/dist/zone.js:1517:14)
        at XMLHttpRequest.globalZoneAwareCallback (https://127.0.0.1:470/node_modules/zone.js/dist/zone.js:1554:21)
    Error loading https://127.0.0.1:470/node_modules/ngx-cookie-service/cookie-service as "ngx-cookie-service" from https://127.0.0.1:470/src/app/app.module.js

谢谢

0 个答案:

没有答案