如何解决 Angular 8 ASP.NET 中的此构建错误 [英] How to resolve this build error in Angular 8 ASP.NET

查看:31
本文介绍了如何解决 Angular 8 ASP.NET 中的此构建错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到此错误无法找到模块@angular/core".并搜索 SO 寻求帮助,但有问题但没有任何帮助.

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

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

并得到相同的错误

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 /"

我删除了 node_modules 文件夹并进行了 npm install

I deleted the node_modules folder and did npm install

我根据@HariniP 的建议运行了命令,谢谢!

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

npm i @angular/core

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>

推荐答案

我通过添加 :

True<TypeScriptEmitDecoratorMetadata>True</TypeScriptEmitDecora

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

此链接可能对您有所帮助 打字稿错误

this link might help u TypeScript error

这篇关于如何解决 Angular 8 ASP.NET 中的此构建错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆