Reputation: 481
I'm following Tour of Heroes tutorial for building my first app.I have written a component file threads.component.ts as follows:
@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?
Upvotes: 3
Views: 3852
Reputation: 5719
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.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;
}
Upvotes: 7