简体   繁体   English

Angular 2和CommonJS相对路径

[英]Angular 2 and CommonJS Relative Paths

I'm trying to use module: module.id in my Angular 2 Components to use relative paths in the components. 我正在尝试在Angular 2组件中使用module: module.id以在组件中使用相对路径。 I referenced this article here and want to use the CommonJS option. 在这里引用了本文,并希望使用CommonJS选项。

I have also checked other Stack Overflow questions, like this one , and followed its instructions by installing the node typings. 我还检查了其他类似 Stack Overflow的问题,并按照其说明安装了节点类型。

After doing all that, I believe it's working, seeing as how the app loads in the browser and works as expected, but my gulp project shows an error of: 完成所有这些操作后,我认为它可以正常工作,可以看到应用程序如何在浏览器中加载并按预期工作,但是我的gulp项目显示以下错误:

error: TS2304: Cannot find name 'module'.

I'm not sure why the error pops up in gulp but the app still loads. 我不确定为什么在gulp中会弹出错误,但该应用程序仍会加载。 Does anyone have any ideas as to why this would happen? 是否有人对为什么会发生有任何想法? Is there something I can do to let gulp know so the error doesn't show up in the build process? 有什么我可以做的让gulp知道的,这样错误就不会在构建过程中出现了吗?

After some more digging and getting kind of lucky, I realized that the index.d.ts file with the reference to the node typings wasn't included in the typescript transpiling task in my build process. 经过更多的挖掘和幸运之后,我意识到在构建过程中,typescript转换任务中未包含引用节点类型的index.d.ts文件。 Once adding that in there, the errors disappeared. 一旦在其中添加错误,错误就消失了。

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

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