The problem (as outlined in typescript getting error TS2304: cannot find name ‘ require’) is that the type definitions for node are not installed.
With a projected genned with @angular/cli 1.x
, the specific steps should be:
Step 1:
Install @types/node
with either of the following:
- npm install --save @types/node
- yarn add @types/node -D
Step 2:
Edit your src/tsconfig.app.json file and add the following in place of the empty "types": []
, which should already be there:
...
"types": [ "node" ],
"typeRoots": [ "../node_modules/@types" ]
...
If I’ve missed anything, jot a comment and I’ll edit my answer.