Why go through the trouble of delivering numerous heavy packages for a small project?
There really is no point.
If you plan on sharing it with other developers, simply ignore the node_modules
or bower_components
directories (or remove them from the shared package). Developers can easily install the dependencies again when needed ;)
If your project involves basic things like HTML templates, node may just be there to simplify your life as a developer by offering live reload, compiling/transpiling features for languages like TypeScript, Babel, SCSS, SASS, LESS, CoffeeScript... (the list goes on ;P), and so on.
In this scenario, dependencies are likely to only be dev_dependencies and not necessary in a production environment ;)
Many packages also come with separate production and dev dependencies, so you only need to install production dependencies...
npm install --only=prod
If your project requires many libraries in production and you want to avoid unnecessary bloat, you could manually include the CSS/JS files that your project needs (but this can be quite a tedious task).
Update
Production vs Default Installation
Most projects have different dev and production dependencies.
Dev dependencies might include compilers for SASS, TypeScript, etc., minifiers for code (uglifiers), tools like live reload, and so on.
On the other hand, the production version will exclude those elements, reducing the size of the node_modules
directory.
** No node_modules
**
In certain HTML template projects, there may be no need for any node_modules
in production, so skipping an npm install
is possible.
No Access to node_modules
Alternatively, in some cases where the server handling everything resides within the node_modules itself, access to these files may be blocked (as they are not meant to be accessed from the frontend).