我正在尝试将我的应用程序从 angular 2 升级到 angular 5。我已经更新了所有依赖项,一切都很好。但是,当我尝试运行我的应用程序时,ngx-cookie-service 库会产生问题。
在 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")
},
我知道调试并不多,如果其他人遇到这个问题仍然可以提供帮助。