cannot find module 'angular2/core'

前端 未结 15 1618
臣服心动
臣服心动 2020-12-23 16:10

These red squiggly lines say cannot find module \'angular2/core\',cannot find module \'angular2/router\',cannot find module \'angula

相关标签:
15条回答
  • 2020-12-23 16:45

    Right click on "package.json" then select Install packages option it will open terminal and automatically navigate to the correct root folder and will install the required dependencies.

    The package.json lists down all the list of dependencies the project needs to run.

    0 讨论(0)
  • 2020-12-23 16:47

    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.

    0 讨论(0)
  • 2020-12-23 16:48
    This has to be done for both 'Debug' and 'Release' then only it works in VS 2013. Like below..
    
    <PropertyGroup Condition="'$(Configuration)' == 'Release'">
        <TypeScriptTarget>ES5</TypeScriptTarget>
        <TypeScriptJSXEmit>None</TypeScriptJSXEmit>
        <TypeScriptCompileOnSaveEnabled>True</TypeScriptCompileOnSaveEnabled>
        <TypeScriptNoImplicitAny>False</TypeScriptNoImplicitAny>
        <TypeScriptModuleKind>system</TypeScriptModuleKind>
        <TypeScriptRemoveComments>False</TypeScriptRemoveComments>
        <TypeScriptOutFile />
        <TypeScriptModuleResolution>NodeJs</TypeScriptModuleResolution>
        <TypeScriptOutDir />
        <TypeScriptGeneratesDeclarations>False</TypeScriptGeneratesDeclarations>
        <TypeScriptNoEmitOnError>True</TypeScriptNoEmitOnError>
        <TypeScriptSourceMap>True</TypeScriptSourceMap>
        <TypeScriptMapRoot />
        <TypeScriptSourceRoot />
        <TypeScriptEmitDecoratorMetadata>True</TypeScriptEmitDecoratorMetadata>
        <TypeScriptExperimentalDecorators>True</TypeScriptExperimentalDecorators>
    </PropertyGroup>
    
    <PropertyGroup Condition="'$(Configuration)' == 'Debug'">
        <TypeScriptTarget>ES5</TypeScriptTarget>
        <TypeScriptJSXEmit>
        </TypeScriptJSXEmit>
        <TypeScriptCompileOnSaveEnabled>True</TypeScriptCompileOnSaveEnabled>
        <TypeScriptNoImplicitAny>False</TypeScriptNoImplicitAny>
        <TypeScriptModuleKind>system</TypeScriptModuleKind>
        <TypeScriptRemoveComments>False</TypeScriptRemoveComments>
        <TypeScriptOutFile />
        <TypeScriptModuleResolution>NodeJs</TypeScriptModuleResolution>
        <TypeScriptOutDir />
        <TypeScriptGeneratesDeclarations>False</TypeScriptGeneratesDeclarations>
        <TypeScriptNoEmitOnError>True</TypeScriptNoEmitOnError>
        <TypeScriptSourceMap>True</TypeScriptSourceMap>
        <TypeScriptMapRoot />
        <TypeScriptSourceRoot />
        <TypeScriptEmitDecoratorMetadata>True</TypeScriptEmitDecoratorMetadata>
        <TypeScriptExperimentalDecorators>True</TypeScriptExperimentalDecorators>
    </PropertyGroup>
    
    0 讨论(0)
提交回复
热议问题