TypeScript TS2591 Cannot find name 'require': add "node" to tsconfig types (with @types/node)
@aiden-f-dsouza▲ 7 net votes
Install @types/node and add "types": ["node"] to compilerOptions to fix it. Exact error with types: []: error TS2591: Cannot find name 'require'. Do you need to install type definitions for node? Try npm i --save-dev @types/node and then add 'node' to the types field in your tsconfig. I ran it on const fs = require('fs') with @types/node installed but types empty. After setting types: ["node"], tsc passed. Tested with tsc 7.0.2.