SolvedDefinitelyTyped error TS2304: Cannot find name 'Set'. 815 allowedNodeEnvironmentFlags: Set<string>;

λ node -v

λ npm -v

λ npm install typescript -g
C:\Users\dell\AppData\Roaming\npm\tsc -> C:\Users\dell\AppData\Roaming\npm\node_modules\typescript\bin\tsc
C:\Users\dell\AppData\Roaming\npm\tsserver -> C:\Users\dell\AppData\Roaming\npm\node_modules\typescript\bin\tsserver
+ typescript@3.0.3
updated 1 package in 3.061s

λ tsc --version
Version 3.0.3

λ mkdir typescript_learning

λ cd typescript_learning

λ npm init -y
Wrote to D:\workshop\www\typescript_learning\package.json:

  "name": "typescript_learning",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  "keywords": [],
  "author": "",
  "license": "ISC"

D:\workshop\www\typescript_learning  (typescript_learning@1.0.0)
λ tsc --init
message TS6071: Successfully created a tsconfig.json file.

D:\workshop\www\typescript_learning  (typescript_learning@1.0.0)
λ npm install @types/node --dev-save
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN typescript_learning@1.0.0 No description
npm WARN typescript_learning@1.0.0 No repository field.

+ @types/node@10.11.0
added 1 package from 30 contributors in 1.657s

D:\workshop\www\typescript_learning  (typescript_learning@1.0.0)
λ touch helloworld.ts

D:\workshop\www\typescript_learning  (typescript_learning@1.0.0)
λ tsc helloworld.ts
node_modules/@types/node/index.d.ts:815:38 - error TS2304: Cannot find name 'Set'.

815         allowedNodeEnvironmentFlags: Set<string>;


var a:string = "HelloWorld"

What should I do?

22 Answers

✔️Accepted Answer

Same here with target and lib as es6.
I've managed to fix this by installing @types/node@12.7.4.

Other Answers:

Add "lib": ["es6"] or higher.

I came across this same issue and was confused because my tsconfig.json has exactly what the error message says to do. Modifying my tsconfig.json further would not fix the issue.

When you pass a file path to tsc, I believe the tsconfig.json is ignored. This is what was happening to me.

tsc src/foo.ts # results in compiler errors stating to upgrade my lib/target
tsc # works fine because my tsconfig.json was specifying a target of es2015 or later

So if you're getting this and your tsconfig.json looks good, double check if you're passing a custom path to the compiler, and potentially ignoring your config.

Yes, I can confirm. Your answer fixes the issue.
Here #29172 (comment)

@andy-ms Thanks. After npm rm @types/node -D, this issue is gone.

More Issues: