angular2:找不到模块"@ angular/core"

编程入门 行业动态 更新时间:2024-10-23 11:32:18
本文介绍了angular2:找不到模块"@ 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"

本文发布于:2023-11-15 10:32:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1593641.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:找不到   模块   core   angular   quot

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!