gpt4 book ai didi

visual-studio - 找不到模块 'angular2/core'

转载 作者:太空狗 更新时间:2023-10-29 16:46:10 25 4
gpt4 key购买 nike

enter image description here

这些红色波浪线表示找不到模块'angular2/core'找不到模块'angular2/router'找不到模块'angular2/http '。我查看了 SO 中的其他帖子但他们似乎没有合适的答案。

我还添加了对 d.ts 文件的引用,如下所示,但仍然无法正常工作。 enter image description here

其他帖子说我需要在 tsconfig.json 文件中配置一些东西,但我使用的是 Visual Studio,我认为不需要使用 Angular 团队建议的 tscompiler,因为 Visual Studio 应该是能够自动编译ts文件。

我错过了什么吗?

即使您使用 Visual Studio,是否仍然需要 tsconfig.json

如何去除这些波浪线?

谢谢!

(我正在使用 Visual Studio 2015 和最新的 Typescript 引擎)

更新:我不确定 npm 包管理器到底是什么。但是我有一个预构建的 package.json 文件,它是在创建项目时创建的。我使用这个文件来安装 npm 包。 enter image description here

最佳答案

对于 VS 2015 中的 ASP.NET 5.0 应用程序,配置 typescript 有点挑战。

在围绕 typescript 的工具改进之前,您可以手动配置 typescript:

Step 1: Right-click project, and Unload Project 
Step 2: Right-click the unloaded project, and Edit the .xproj file
Step 3: Add a PropertyGroup node, under the Project node:

<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<TypeScriptTarget>ES5</TypeScriptTarget>
<TypeScriptJSXEmit>None</TypeScriptJSXEmit>
<TypeScriptCompileOnSaveEnabled>True</TypeScriptCompileOnSaveEnabled>
<TypeScriptNoImplicitAny>False</TypeScriptNoImplicitAny>
<TypeScriptModuleKind>CommonJS</TypeScriptModuleKind>
<TypeScriptRemoveComments>False</TypeScriptRemoveComments>
<TypeScriptOutFile />
<TypeScriptOutDir />
<TypeScriptGeneratesDeclarations>False</TypeScriptGeneratesDeclarations>
<TypeScriptNoEmitOnError>True</TypeScriptNoEmitOnError>
<TypeScriptSourceMap>True</TypeScriptSourceMap>
<TypeScriptMapRoot />
<TypeScriptSourceRoot />
<TypeScriptExperimentalDecorators>True</TypeScriptExperimentalDecorators>
</PropertyGroup>

Step 4: Right-click the unloaded project and Reload Project
Step 5: Re-build project

如果您仍然遇到找不到模块的错误,请退出 visual studio 并重新加载解决方案。

关于visual-studio - 找不到模块 'angular2/core',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34488669/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com