Skip to content
FLAVIO COPES
flaviocopes.com
2026

Fix Node.js imports types errors in VS Code

By

How to fix VS Code complaining that Node.js types cannot be found, by installing @types/node, adding it to tsconfig, and restarting the editor.

~~~

Had this error (more a warning) in a project:

VS Code showing TypeScript errors with red underlines on Node.js imports for fs, process, and path modules

VS Code complained Node.js types could not be found.

So I installed them:

npm install -D @types/node

Then added them to the compilerOptions in tsconfig.json

{
  //...
  "compilerOptions": {
    "types": [
      "node"
    ]
  },
}

That still didn’t solve so I dropped node_modules:

rm -rf node_modules
rm -f package-lock.json
npm cache clean --force
npm install

Finally, restarting VS Code made them disappear (not sure if reinstalling modules had any effect, first try restarting VS Code after adding the types).

Tagged: Node.js · All topics
~~~

Related posts about node: