vitejs / vite

Next generation frontend tooling. It's fast!
http://vite.dev
MIT License
68.46k stars 6.18k forks source link

Add @types/node as devDependency to all typescript templates #18600

Open smeng9 opened 2 days ago

smeng9 commented 2 days ago

Description

When following official guides that imports path library or use __dirname in https://vite.dev/guide/build.html#multi-page-app we will encounter typescript errors.

Screenshot 2024-11-06 at 10 09 19 AM

This is not a very good developer experience.

Suggested solution

Add @types/node to devDependencies of vite templates.

Alternative

Add a description section in the document that user needs to import such library or change tsconfig.node.json settings.

Additional context

No response

Validations

bluwy commented 23 hours ago

Seems fair to me 👍 The tricky thing I guess is that users may want to align the node version to the one they're using locally while calling npm create vite. Maybe that can be separately tackled if needed.