ASP.NET Core prerender错误(需要'deps')

问题描述 投票:1回答:1

使用aspnet-prerendering时,我在ASP.NET Core 2.0应用程序中收到以下错误:

NodeInvocationException: StaticInjectorError[{provide:PlatformLocation, useClass:ServerPlatformLocation}]: 'deps' required
Error: StaticInjectorError[{provide:PlatformLocation, useClass:ServerPlatformLocation}]: 'deps' required

在我的boot.server.ts我有

import { platformDynamicServer, PlatformState, INITIAL_CONFIG } from '@angular/platform-server';

的package.json

  "devDependencies": {
    "@angular/animations": "4.2.5",
    "@angular/common": "4.2.5",
    "@angular/compiler": "4.2.5",
    "@angular/compiler-cli": "4.2.5",
    "@angular/core": "4.2.5",
    "@angular/forms": "4.2.5",
    "@angular/http": "4.2.5",
    "@angular/platform-browser": "4.2.5",
    "@angular/platform-browser-dynamic": "4.2.5",
    "@angular/platform-server": "4.2.5",
    "@angular/router": "4.2.5",
    "@ngtools/webpack": "1.5.0",
    "@types/webpack-env": "1.13.0",
    "angular2-router-loader": "0.3.5",
    "angular2-template-loader": "0.6.2",
    "aspnet-prerendering": "^3.0.1",
    "aspnet-webpack": "^2.0.1",
    "awesome-typescript-loader": "3.2.1",
...
    "typescript": "2.4.1",
    "url-loader": "0.5.9",
    "webpack": "2.5.1",
    "webpack-hot-middleware": "2.18.2",
    "webpack-merge": "4.1.0",
...
  },
  "dependencies": {
    "ngx-cookie": "^2.0.1"
  }

有人可以帮我解决这个错误吗?我应该在某处添加导入或提供输入吗?哪里?谢谢。

angular single-page-application asp.net-core-2.0
1个回答
0
投票

为了让其他人知道,有兴趣的人,并感谢他们的帮助,我在这里发布了我设法解决这个问题的方法。

svoychik与我分享了一个开箱即用的ngx-cookie启动项目。 Here is the repo on github

以这个项目作为起点,我现在正在使用该服务,但我不能告诉你在VS2017的现有项目中无法实现它的原因是什么(从库存新项目ASP.NET web生成网站模板)。

作为参考,这是我们在ngx-cookie github上的对话。

祝好运。

© www.soinside.com 2019 - 2024. All rights reserved.