TL;DR
A possible fix for this is to import the types for Node.js.
Full Solution
The solution for this issue is to import the types for Node.js.
This is available as an npm package. It contains all of the types for Node.js.
To install it, you need to run the following command.
$ npm install --save-dev @types/node
The reason the --save-dev flag is on the install command is because it isn't supposed to be a dependency, but instead a dev (development) dependency. This will not install this package if, for example, your project is installed as an npm module.
After this, IntelliSense will automatically pick up the type definitions, and will add auto-correct your Node.js code, including doing some other handy things.
If the type definitions don't get picked up, then the best solution is to restart Visual Studio Code. If that doesn't work, make sure that this is in your package.json file.
{
"devDependencies": {
"@types/node": "^17.0.31"
}
}
Note: The version was correct at the time of post.
If it isn't, then add that code in your package.json file, save it, and run the following command.
$ npm install
This should install it successfully.