How to resolve this build error in Angular 8 ASP.NET

﹥>﹥吖頭↗ 提交于 2019-12-12 06:46:18

问题


I get this error Cannot find module '@angular/core'. and search SO for help on this and there are questions but nothing helps me.

Does this has to do with wrong version import? In the command windows I run

L:\NetProject\BooksProject\BooksProject\ClientApp>ng build

and get the same error

BooksProject> 
BooksProject> fail: Microsoft.AspNetCore.SpaServices[0]
BooksProject>       ERROR in ../../../node_modules/@angular/cdk/bidi/typings/dir-document-token.d.ts(8,32): error TS2307: Cannot find module '@angular/core'.
BooksProject>       ../../../node_modules/@angular/cdk/bidi/typings/dir.d.ts(8,59): error TS2307: Cannot find module '@angular/core'.
BooksProject>       ../../../node_modules/@angular/cdk/bidi/typings/directionality.d.ts(8,41): error TS2307: Cannot find module '@angular/core'.
BooksProject>       ../../../node_modules/@angular/cdk/text-field/typings/autofill.d.ts(9,69): error TS2307: Cannot find module '@angular/core'.
BooksProject>       ../../../node_modules/@angular/cdk/text-field/typings/autofill.d.ts(10,28): error TS2307: Cannot find module 'rxjs'.
BooksProject>       ../../../node_modules/@angular/cdk/text-field/typings/autosize.d.ts(8,71): error TS2307: Cannot find module '@angular/core'.
BooksProject> 

If I debug the app a get browser window with only the text, "Cannot GET /"

I deleted the node_modules folder and did npm install

I run the command after suggestion from @HariniP, Thanks!

npm i @angular/core

And this is the output, do I need to fix all this WARN?

L:\NetProject\BooksProject\BooksProject\ClientApp>npm i @angular/core
npm WARN @angular/material@7.3.7 requires a peer of @angular/cdk@7.3.7 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/platform-server@8.1.0-next.1 requires a peer of @angular/animations@8.1.0-next.1 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/platform-server@8.1.0-next.1 requires a peer of @angular/common@8.1.0-next.1 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/platform-server@8.1.0-next.1 requires a peer of @angular/compiler@8.1.0-next.1 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/platform-server@8.1.0-next.1 requires a peer of @angular/core@8.1.0-next.1 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/platform-server@8.1.0-next.1 requires a peer of @angular/platform-browser@8.1.0-next.1 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/platform-server@8.1.0-next.1 requires a peer of @angular/platform-browser-dynamic@8.1.0-next.1 but none is installed. You must install peer dependencies yourself.
npm WARN The package protractor is included as both a dev and production dependency.
npm WARN The package ts-node is included as both a dev and production dependency.
npm WARN The package tslint is included as both a dev and production dependency.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ @angular/core@8.0.0
updated 1 package and audited 19503 packages in 33.58s
found 1 moderate severity vulnerability
  run `npm audit fix` to fix them, or `npm audit` for details

L:\NetProject\BooksProject\BooksProject\ClientApp>

回答1:


i fixed my problem by adding :

<TypeScriptExperimentalDecorators>True</TypeScriptExperimentalDecorators> <TypeScriptEmitDecoratorMetadata>True</TypeScriptEmitDecora

this link might help u TypeScript error




回答2:


Install angular by using the command npm i @angular/core in your project directory.



来源:https://stackoverflow.com/questions/56586046/how-to-resolve-this-build-error-in-angular-8-asp-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!