【发布时间】:2016-09-25 20:24:22
【问题描述】:
我按照 angular2 quick start 创建了我的项目,一切正常,但我的“tsc -w”命令行不断告诉我:
app/components/company/company.ts(1,36): error TS2307: Cannot find module '@angular/core'.
app/components/company/company.ts(5,22): error TS2307: Cannot find module '@angular/router'.
app/components/mission/mission.ts(1,36): error TS2307: Cannot find module '@angular/core'.
app/components/mission/mission.ts(3,22): error TS2307: Cannot find module '@angular/router'.
还有很多其他这样的行。然而,一切都编译成功,我的应用程序工作正常,但是将所有这些警告/错误作为真正的错误,在它们中间丢失了东西,这很烦人。
我正在使用 Angular2 rc1、TypeScript 1.8.10、WebStorm EAP(虽然我没有使用 WebStorm TypeScript 编译系统,但我使用的是带有“tsc -w”命令行的开放终端)。
我在 SO 上查看了与此相关的其他问题,但没有发现任何真正帮助我的东西。
更新
这是我的 tsconfig.json 文件:
{
"compilerOptions": {
"target": "es5",
"sourceMap": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"module": "system",
"noImplicitAny": false,
"outDir": "js",
"rootDir": "app"
},
"exclude": [
"node_modules",
"typings/main",
"typings/main.d.ts"
]
}
【问题讨论】:
-
嗯...显然,自从我创建项目以来,这个文件已经在快速启动中发生了变化。在我的打字中,我只有“es6-shim”、“jasmine”和“node”。但是,我现在看到,在快速入门中,“es6-shim”被“core-js”取代,但我觉得它不能解决我的问题(我错了吗?)。此外,“Thierry Templier”提出的解决方案是可行的。谢谢
标签: typescript angular