找不到模块“angular2/core" [英] cannot find module 'angular2/core'
问题描述
这些红色波浪线表示cannot find module 'angular2/core'
,cannot find module 'angular2/router'
,cannot find module 'angular2/http'代码>.我查看了
其他帖子说我需要在 tsconfig.json
文件中配置一些东西,但我使用的是 Visual Studio,我认为没有必要使用 angular 团队建议的 tscompiler,因为 Visual Studio 应该是能够自动编译ts文件.
我错过了什么吗?
即使您使用 Visual Studio 仍然需要 tsconfig.json
吗?
如何去掉这些波浪线?
谢谢!
(我使用的是 Visual Studio 2015 和最新的 Typescript 引擎)
更新:我不确定 npm 包管理器到底是什么.但是我有一个预构建的 package.json
文件,该文件是在创建项目时创建的.我使用这个文件来安装 npm 包.
对于 VS 2015 中的 ASP.NET 5.0 应用程序,配置 typescript 有点挑战.
在围绕打字稿的工具改进之前,您可以手动配置打字稿:
第一步:右键工程,卸载工程步骤 2:右键单击卸载的项目,然后编辑 .xproj 文件第三步:在Project节点下添加一个PropertyGroup节点:<PropertyGroup Condition="'$(Configuration)' == 'Debug'"><TypeScriptTarget>ES5</TypeScriptTarget><TypeScriptJSXEmit>无</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>第 4 步:右键单击卸载的项目并重新加载项目第 5 步:重新构建项目
如果您仍然遇到找不到模块的错误,请退出visual studio并重新加载解决方案.
These red squiggly lines say cannot find module 'angular2/core'
,cannot find module 'angular2/router'
,cannot find module 'angular2/http'
.
I checked other posts in SO but it seems they have no appropriate answer.
I also added a reference to the d.ts
files as seen below but still not working.
Other posts say that I need to configure something in the tsconfig.json
file but I am using Visual Studio and I see no need to use the tscompiler suggested by the angular team because Visual Studio should be able to compile ts files automatically.
Am I missing something?
Is the tsconfig.json
still required even if you use Visual Studio?
How do I get rid of these squiggly lines?
Thanks!
(I am using Visual Studio 2015 and latest Typescript engine)
UPDATE:
I am not sure what exactly is the npm package manager. But I have a pre-built package.json
file that was created when the project was created. I use this file for installing npm packages.
For ASP.NET 5.0 applications in VS 2015, configuring typescript is a bit challenging.
Until the tooling around typescript improves, you can configure typescript manually:
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
If you are still encountering the error where it cannot find the module, exit visual studio and reload the solution.
这篇关于找不到模块“angular2/core"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!