npmprune.sh
is an lightweight script designed to clean up your node_modules
directory by removing unnecessary files like Markdown, doc and config files.
It helps in reducing the overall size of node_modules
, optimizing storage space, and speeding up deployments, especially in containerized environments.
By detecting NODE_ENV
, it can perform a more aggressive cleanup, tailored for production builds such as in Docker containers.
wget -O /usr/local/bin/npmprune https://raw.githubusercontent.com/xthezealot/npmprune/master/npmprune.sh && chmod +x /usr/local/bin/npmprune
- Ensure you have execution permissions:
chmod +x npmprune.sh
- Run the script in your project directory:
./npmprune.sh
- Open PowerShell.
- Navigate to your project directory.
- Run the script:
.\npmprunewin.ps1
The PowerShell version, npmprunewin.ps1
, performs similar functions as the shell script but is tailored for Windows environments. It leverages PowerShell commands to efficiently clean the node_modules
directory, taking into consideration the Windows filesystem and permissions.
If the NODE_ENV
environment variable is set to production
, NPMprune performs a more extensive cleanup by also removing type definitions.
wget -qO- https://raw.githubusercontent.com/xthezealot/npmprune/master/npmprune.sh | sh
RUN wget -qO- https://raw.githubusercontent.com/xthezealot/npmprune/master/npmprune.sh | sh
NPMprune is compatible with Windows, Linux and macOS environments, even with the most basic Alpine Linux setup.