angular2:找不到模块"@ angular/core" [英] angular2: Cannot find module '@angular/core'
问题描述
我按照angular2 快速启动创建了我的项目,一切正常但是我的"tsc -w"命令行不断告诉我:
I followed the angular2 quick start to create my project and everything works fine but my "tsc -w" command line keeps on telling me:
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'.
还有很多其他类似的内容.但是,所有内容都可以成功编译,并且我的应用程序可以正常工作,但是将所有这些警告/错误作为真正的错误在其中途丢失会很烦人.
And there is plenty of other line like this. However, everything is compiled successfully and my application works fine, but it's quite annoying to have all these warnings/errors as real errors something get lost in the middle of them.
我正在使用Angular2 rc1,TypeScript 1.8.10,WebStorm EAP(虽然我没有使用WebStorm TypeScript编译系统,但我依靠的是带有"tsc -w"命令行的开放式终端).
I'm using Angular2 rc1, TypeScript 1.8.10, WebStorm EAP (altough I'm not using the WebStorm TypeScript compilation system, I'm relying on an open terminal with "tsc -w" command line).
我在SO上检查了与此相关的其他问题,但没有发现任何真正对我有帮助的东西.
I checked other question related to that on SO, but I didn't find anything that really helped me.
更新
这是我的tsconfig.json文件:
Here is my tsconfig.json file:
{
"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"
]
}
推荐答案
您应将moduleResolution
属性用于node
:
{
"compilerOptions": {
"target": "es5",
"sourceMap": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"module": "system",
"moduleResolution": "node", // <-----
"noImplicitAny": false,
"outDir": "js",
"rootDir": "app"
},
"exclude": [
"node_modules",
"typings/main",
"typings/main.d.ts"
]
}
这篇关于angular2:找不到模块"@ angular/core"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!