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?
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;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.