无法使用角度为5的ngx-cookie-service

时间:2018-06-01 08:56:22

标签: angular cookies

我正在尝试将我的应用程序从角度2升级到角度5.我已经更新了所有依赖项,并且一切正常。但是,当我尝试运行我的应用程序时,ngx-cookie-service库正在创建问题。 / p>

在app.module.ts中,我正在导入cookieservice并添加到providers数组。

import { CookieService } from 'ngx-cookie-service';
providers: [ CookieService, ApiService, {provide: LocationStrategy, useClass: HashLocationStrategy} ]

在我的api.service.ts中,

import { CookieService } from 'ngx-cookie-service';

在构造函数中,我实例化它

    constructor(private http: HttpClient, 
                private _cookieService:CookiesService, 
                private router: Router) {}

我正在使用webpack构建并在运行我的应用程序时,我收到此错误

VM2645:1 Uncaught SyntaxError: Unexpected token export
    at Object.48 (app.a4460e7c733950106cd8.js:formatted:9)
    at __webpack_require__ (polyfills.89065a9ec9d93329d461.js:1)
    at eval (eval at 47 (app.a4460e7c733950106cd8.js:formatted:6), <anonymous>:11:17)
    at Object.47 (app.a4460e7c733950106cd8.js:formatted:6)
    at __webpack_require__ (polyfills.89065a9ec9d93329d461.js:1)
    at Object.eval (eval at 0 (app.a4460e7c733950106cd8.js:formatted:3), <anonymous>:5:20)
    at eval (eval at 0 (app.a4460e7c733950106cd8.js:formatted:3), <anonymous>:11:30)
    at Object.0 (app.a4460e7c733950106cd8.js:formatted:3)
    at __webpack_require__ (polyfills.89065a9ec9d93329d461.js:1)
    at window.webpackJsonp (polyfills.89065a9ec9d93329d461.js:1)
    at app.a4460e7c733950106cd8.js:formatted:1

突出显示错误,

function(module, exports) {
        eval("export * from './cookie-service/cookie.service';\n//# sourceMappingURL=index.js.map//# sourceMappingURL=data:application/json;charset=utf-8;base64")
    },

我知道调试并不多,如果其他人遇到此问题可以提供帮助。

1 个答案:

答案 0 :(得分:0)

可能只是api.service.ts中的拼写错误。 它不是“CookiesService”,它的“CookieService”