Solvedangular starter [at-loader] cannot find name 'require'.

Followed the instructions in readme and executed npm start and I am getting below errors.

[at-loader] Checking finished with 6 errors
[at-loader] Cannot find type definition file for 'hammerjs'.

[at-loader] Cannot find type definition file for 'node'.

[at-loader] src\app\app.component.ts:19:5
Cannot find name 'require'.

[at-loader] src\app\home\home.component.ts:20:13
Cannot find name 'require'.

[at-loader] src\app\home\home.component.ts:22:13
Cannot find name 'require'.

[at-loader] src\polyfills.browser.ts:44:3
Cannot find name 'require'.

20 Answers

✔️Accepted Answer

matb
123

I was able to solve the problem by changing line 106 of webpack.common.js from

'awesome-typescript-loader?{configFileName: "tsconfig.webpack.json"}',

to

'awesome-typescript-loader?{tsconfig: "tsconfig.webpack.json"}',

Other Answers:

Solution:
If you have your separated tsconfig in NON-root folder (e.g. config folder), you have to set typeRoots prop of this config to be relative (e.g. "../node_modules/@types")

This appears to be a bug affecting just Windows with TypeScript 2.1.5. It goes away when downgrading to TypeScript 2.0.10.

But I found a better solution:
Just above "types:" in both tsconfig.json files add the following:

"typeRoots": [
      "node_modules/@types"
    ],

TypeScript should automatically look there, but it appears this is failing on Windows.

More Issues: