Skip to content

TypeScript doesn't add "node" to "types" in compilerOptions, even though node_modules/@types/node exists #63753

Description

@karl-police

🔎 Search Terms

"typescript default config values", "default tsconfig", "What config is used when there's no tsconfig", "What is tsc part of?", "Cannot find name 'process'. 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.", "After installing tsx it broke process", "Is tsconfig part of the typescript repository?"

🕗 Version & Regression Information

  • Versions: "typescript": "^7.0.2" was the version configured

⏯ Playground Link

No response

💻 Code

console.log(process.env)

🙁 Actual behavior

Cannot find name 'process'. 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.

🙂 Expected behavior

The documentation here https://www.typescriptlang.org/tsconfig/#types says:

By default all visible ”Types (@types)” packages are included in your compilation. Packages in node_modules/@types of any enclosing folder are considered visible. For example, that means packages within ./node_modules/@types/, ../node_modules/@types/, ../../node_modules/@types/, and so on.

So, if @types/node is present, why doesn't it include it

Additional information about the issue

Description

The documentation here https://www.typescriptlang.org/tsconfig/#types says:

By default all visible ”Types (@types)” packages are included in your compilation. Packages in node_modules/@types of any enclosing folder are considered visible. For example, that means packages within ./node_modules/@types/, ../node_modules/@types/, ../../node_modules/@types/, and so on.

So, I should ever see

Cannot find name 'process'. 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.

But I do see it, why does it happen, how can I debug this issue. I've tried basic things but I feel like either there's some cache file or something, or I do not understand why it suddenly came back again.

Re-production Steps

Unclear but

  • Create a file and name it index.tsx
  • npm install --save-dev @types/node``
  • Add console.log(process.env) in the file
  • Restart VS Code

not guaranteed, I need help debugging

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions