繁体   English   中英

我的angular2导入代码有什么问题

[英]what's wrong with my angular2 import code

如下面的代码,我是angular2的新手,为什么当我使用“ app / app.module”时,灯光服务器返回错误:

import {AppModule} from "app/app.module";//wrong
import {AppModule} from "./app.module";  //right

app / main.ts(5,25):错误TS2307:找不到模块“ /app/app.module”。

有什么问题?有没有办法使用"app/app.module"

这是结构图像,正好流过2个tut。

我认为问题是由于tsconfig.json从角度2 tut。 但我不知道如何解决。

谢谢大家

您的两个示例都使用相对路径

AppModule的路径是相对于您当前文件的。

如果使用Webpack或SystemJS导入,则应遵循此约束

AppModule _> same folder

./AppModule -> inside a file

../AppModule -> go out from current directory

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM