cannot find module 'angular2/core'

前端 未结 15 1619
臣服心动
臣服心动 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:40

    Developing with the ASP.NET Core Angular 2 Starter Application template from Mads Kristensen. I had a similar problem starting a new directory with Typescript files.

    My solution was more simple than modifying the project file. I just copied the tsconfig.json from the ClientApp folder where all of the typescript files were to my new folder.

    0 讨论(0)
  • 2020-12-23 16:41
    1. In Visual Studio 2015, go to "Tools" menu and click on "Options...". You will be able to see a tree structure on the left side of the opened window.
    2. Expand "Projects and Solutions" and then select "External Web Tools". Now move "$(PATH)" entry above the "$(DevEnvDir)" entry.
    3. Click OK. Restart the Visual Studio.
    4. Now right click on the "package.json" file in the solution explorer and click on "Restore Packages".
    0 讨论(0)
  • 2020-12-23 16:41

    Hi I got the same problem when I am using eclplse editor . I have executed the below command in my cmd window and I have restarted my eclipse . It is working as expected.

    npm install --save @angular/core @angular/compiler @angular/common @angular/platform-browser @angular/platform-browser-dynamic rxjs@5.0.0-beta.6 zone.js@0.6.12 @angular/forms

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

    Here is my working settings:

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

    Restart Visual Studio after applying this to your web project.

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

    For VS2015, go to Tools -> Options -> Text Editor -> TypeScript -> Project -> General then tick "Automatically compile TypeScript files which are not part of a project" then select "Use CommonJS code generation for modules.."

    0 讨论(0)
  • This is how I fixed the problem in VS2015 :

    • Open to the project property window
    • Navigate to the TypeScript Build tab
    • Select CommonJS as module system as shown in image below

    0 讨论(0)
提交回复
热议问题