angular - 在 Visual Studio Code IDE 中找不到模块 '@angular/core'

标签 angular typescript

非常简单的代码。但是出现错误 cannot find module '@angular/core'

course.component.ts

import {Component} from '@angular/core'


@Component({
    selector: 'courses'
})
export class CoursesComponent{

}

typings.json

 {
  "ambientDependencies": {
    "es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#6697d6f7dadbf5773cb40ecda35a76027e0783b2"
 }
}

tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "module": "system",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  },
   "exclude": [
   "node_modules",
   "typings/main",
   "typings/main.d.ts"
  ]
}

package.json

{
  "name": "angular2-quickstart",
  "version": "1.0.0",
  "scripts": {
   "start": "concurrent \"npm run tsc:w\" \"npm run lite\" ",
   "tsc": "tsc",
   "tsc:w": "tsc -w",
   "lite": "lite-server",
   "typings": "typings",
   "postinstall": "typings install"
  },
   "license": "ISC",
   "dependencies": {
   "angular2": "2.0.0-beta.7",
   "bootstrap": "^3.3.6",
   "es6-promise": "^3.0.2",
   "es6-shim": "^0.33.3",
   "reflect-metadata": "0.1.2",
   "rxjs": "5.0.0-beta.2",
   "systemjs": "0.19.22",
   "zone.js": "0.5.15"
  },
 "devDependencies": {
  "concurrently": "^2.0.0",
  "lite-server": "^2.1.0",
   "typescript": "^1.7.5"
  }
}

我知道这种问题已经回答过很多次了。但由于我的无知,我仍然不知道。

感谢您的帮助。

编辑

我的文件组织为 capture

最佳答案

对我来说,这是由于没有正确选择 typescript 模块。所以我在 visual studio 项目属性中选择了相同的模块值“tsconfig.json File -> compilerOptions -> module: commonjs”。 enter image description here

关于angular - 在 Visual Studio Code IDE 中找不到模块 '@angular/core',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44548133/

相关文章:

javascript - Angular 2在指向根路由器的子节点中添加routerLink

angular - 如何在多个组件之间使用 Angular 2 的 FormBuilder

javascript - ng2 图表 - 刷新饼图

javascript - 具有 HOC 的命名导出

angular - 获取对当前事件的 HTMLElement 的引用

Angular2 Jasmine 测试图像源

asp.net-mvc - ASP.NET MVC 以小写形式呈现 html 标签和属性

typescript - 如何使用可变参数强类型函数

html - 当我在框外或 Angular 4 框内单击时隐藏覆盖面板

javascript - 在声明的同一文件中使用全局变量吗?