How to download only required dependencies in node js

** My node modules folder is enormous when I am making a local react app**
I have used node js in glitch and repl.it and the npm install only installed packages which were present inside the package.json.
But when I try to create a react app locally then it installs a whopping 200+ megabytes size folder.
How to download only specific modules from my package.json and ignore the rest which are not needed.

Hello there,

You will need to use something like Babel and Webpack, in order to transcribe (transpile?) React into plain JS. This generally requires writing a lot of boilerplate, and I only do it under very specific circumstances.

Generally, you would make do with all of the fluff during development, then when running npm run build the files are packed into a single (usually more than one file) package, which will be optimised for production, and much smaller. No node modules in production.

However, if you really are concerned about disk space on your PC, then perhaps some online searching will yield a GitHub repo with a minimalist React/Babel setup.

Hope this helps

1 Like

That’s normal, it’s packaging up an entire development environment. On replit you’re getting those things implicitly, you don’t need to download them, the tooling is hidden from you. JS does not ship with its own inbuilt tooling (testing, linting, formatting, compilation/packaging for deployment), you have to download libraries and frameworks to do that.

1 Like

This answers my question. Thank you very much. :slight_smile: