Search code examples
webpackangular5asp-net-core-spa-services

Cannot resolve @angular/http in node_modules\@angular\platform-server\bundles in angular 5 aspnet prerendering


I am using Angular 5 with spatemplates in ASPNET Core. Once I updated the packages and modified the webpack.config.js . I am trying to run --

webpack --config webpack.config.js 

to generate the main-server.js and vendor.js. However I am getting the error below. Why is this being thrown?

 ERROR in ./node_modules/@angular/platform-server/bundles/platform-server.umd.js
    Module not found: Error: Can't resolve '@angular/http' in 'D:\Neudesic\eMedHat\eMedHat Web\dev\Source\eMedHat\eMedHat.SurveyPortal\node_modules\@angular\platform-server\bundles'
     @ ./node_modules/@angular/platform-server/bundles/platform-server.umd.js 7:246-270
     @ ./ClientApp/boot.server.ts

My package.json:

{
  "name": "eMedHat.SurveyPortal",
  "private": true,
  "version": "0.0.0",
  "scripts": {
    "test": "karma start ClientApp/test/karma.conf.js"
  },
  "devDependencies": {
    "@angular/animations": "^5.2.6",
    "@angular/cli": "^1.7.1",
    "@angular/common": "^5.2.6",
    "@angular/compiler": "^5.2.6",
    "@angular/compiler-cli": "^5.2.6",
    "@angular/core": "^5.2.6",
    "@angular/forms": "^5.2.6",
    "@angular/platform-browser": "^5.2.6",
    "@angular/platform-browser-dynamic": "^5.2.6",
    "@angular/platform-server": "^5.2.6",
    "@angular/router": "^5.2.6",
    "@ngtools/webpack": "^1.10.1",
    "@types/chai": "4.1.2",
    "@types/jasmine": "2.8.6",
    "@types/webpack-env": "1.13.5",
    "angular2-router-loader": "0.3.5",
    "angular2-template-loader": "0.6.2",
    "aspnet-prerendering": "^3.0.1",
    "aspnet-webpack": "^2.0.3",
    "awesome-typescript-loader": "3.4.1",
    "bootstrap": "4.0.0",
    "chai": "4.1.2",
    "css": "2.2.1",
    "css-loader": "0.28.10",
    "es6-shim": "0.35.3",
    "event-source-polyfill": "0.0.12",
    "expose-loader": "0.7.4",
    "extract-text-webpack-plugin": "^3.0.2",
    "file-loader": "1.1.9",
    "html-loader": "0.5.5",
    "isomorphic-fetch": "2.2.1",
    "jasmine-core": "2.99.1",
    "jquery": "3.3.1",
    "json-loader": "0.5.7",
    "karma": "2.0.0",
    "karma-chai": "0.1.0",
    "karma-chrome-launcher": "2.2.0",
    "karma-cli": "1.0.1",
    "karma-jasmine": "1.1.1",
    "karma-webpack": "^2.0.9",
    "popper.js": "^1.12.9",
    "preboot": "6.0.0-beta.2",
    "raw-loader": "0.5.1",
    "reflect-metadata": "0.1.12",
    "rxjs": "^5.5.6",
    "style-loader": "0.20.2",
    "to-string-loader": "1.1.5",
    "typescript": "^2.6.2",
    "url-loader": "0.6.2",
    "webpack": "^3.11.0",
    "webpack-hot-middleware": "^2.21.0",
    "webpack-merge": "^4.1.2",
    "zone.js": "0.8.20"
  },
  "dependencies": {
    "ngx-bootstrap": "^2.0.2"
  }
}

Solution

  • The issue was it was using npm shrinkwrap . so even if I updated the package.json. I had to still update the shrinkwrap . Else it won't update the packages . The shrinkwrap.json locks down the npm package versions