Webpack (specifically awesome-typescript-loader) fails to build my app because of the following error:
ERROR in [at-loader] ./src/app/app.ts:6:13
TS2304: Cannot find name 'require'.
The associated code:
@Component({
name: 'App',
template: require('./app.template.pug') <---
})
export class AppComponent extends Vue {
}
There's a similiar question here which describes the exact same error, and I've tried various solutions mentioned in the answers, however with no success:
1. Types are installed in package.json
"devDependencies": {
" @types/node": "^7.0.22"
...
2. awesome-typescript-loader
is aware of my tsconfig.json
:
loader: 'awesome-typescript-loader',
options: {
configFileName: 'tsconfig.json',
useCache: config.build.useCaching
}
3. Types
aswell as type roots
have been declared in tsconfig.json
"typeRoots": [
"node_modules/@types"
],
"types": [
"node",
"webpack"
],
4. My custom typings include definitions for node
declare module '*';
declare var require: any
Anything else I could try?