[英]angular2 quickstart cannot find name 'module'
I'm following Tour of Heroes tutorial for building my first app.I have written a component file threads.component.ts as follows: 我正在遵循《英雄之旅》教程来构建我的第一个应用程序,我编写了一个组件文件threads.component.ts,如下所示:
@Component({
moduleId: module.id,
selector: 'Threads',
templateUrl: './threads.component.html',
styleUrls: ['./threads.component.css']
})
but I'm getting the error 'Cannot find name module', what can I do to fix this problem? 但出现错误“找不到名称模块”,该怎么办才能解决此问题?
That is a typescript error. 那是打字稿错误。 You can add the types for node and it gets resolved:
您可以添加节点的类型,它可以解决:
npm install -D @types/node
And in your tsconfig: 并在您的tsconfig中:
//tsconfig.json
{
...
"compilerOptions": {
"types" : ["node"]
}
...
}
Simpler version if you don't want to install types: 如果您不想安装类型,则使用更简单的版本:
add this at top of your component: 将此添加到您的组件顶部:
declare var module: {
id: string;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.