4

While i'm developing my Asp.net Core 2 / Angular 5 app.I have received the following error.

(TS) Cannot find module '@angular/platform-server'.

Here i have attached the screenshot that the error was generated. enter image description here

Here i have add package.json file as well.

  {
  "name": "ASPCoreWithAngular",
  "private": true,
  "version": "0.0.0",
  "scripts": {
    "test": "karma start ClientApp/test/karma.conf.js"
  },
  "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/chai": "4.0.1",
    "@types/jasmine": "2.5.53",
    "@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",
    "bootstrap": "3.3.7",
    "chai": "4.0.2",
    "css": "2.2.1",
    "css-loader": "0.28.4",
    "es6-shim": "0.35.3",
    "event-source-polyfill": "0.0.9",
    "expose-loader": "0.7.3",
    "extract-text-webpack-plugin": "2.1.2",
    "file-loader": "0.11.2",
    "html-loader": "0.4.5",
    "isomorphic-fetch": "2.2.1",
    "jasmine-core": "2.6.4",
    "jquery": "3.2.1",
    "json-loader": "0.5.4",
    "karma": "1.7.0",
    "karma-chai": "0.1.0",
    "karma-chrome-launcher": "2.2.0",
    "karma-cli": "1.0.1",
    "karma-jasmine": "1.1.0",
    "karma-webpack": "2.0.3",
    "preboot": "4.5.2",
    "raw-loader": "0.5.1",
    "reflect-metadata": "0.1.10",
    "rxjs": "5.4.2",
    "style-loader": "0.18.2",
    "to-string-loader": "1.1.5",
    "typescript": "2.4.1",
    "url-loader": "0.5.9",
    "webpack": "2.5.1",
    "webpack-hot-middleware": "2.18.2",
    "webpack-merge": "4.1.0",
    "zone.js": "0.8.12"
  }
}

Can anyone give me a solution to solve this issue. ?

5
  • can you please share your package.json file ? Commented Feb 23, 2018 at 6:32
  • @wessamsalah OP updated. Commented Feb 23, 2018 at 6:34
  • did u try to run -> npm i in your console ? Commented Feb 23, 2018 at 6:38
  • 1
    I have restore package.json file adn problem SOLVED. Commented Feb 23, 2018 at 6:46
  • same way , Good (Y) Commented Feb 23, 2018 at 6:47

4 Answers 4

7

Edits: You can use npm i --save @angular/platform-server

Depending on the error, you can install using npm i @angular/platform-browser to install it manually. This is how I solved the issue on my side.

PS: please use --save flag to save it on your local machine like this npm i --save @angular/platform-browser too.

Sign up to request clarification or add additional context in comments.

1 Comment

It should be npm i --save @angular/platform-server
4

Please run this

npm i --save @angular/platform-server  

on the cli

Comments

2

Use npm i --save @angular/platform-server to install it

Comments

1

i'm using angular 13 and installed angular universal uning: ng add @nguniversal/express-engine

encountered similar issue: 'Cannot find module '@angular/platform-server' or its corresponding type declarations.ts(2307)'

had to manually install and save this package:

npm i --save @angular/platform-browser

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.