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/npmprunenpmpruneIf the NODE_ENV environment variable is set to production, NPMprune performs a more extensive cleanup by also removing type definitions.
You can provide additional patterns by passing them as arguments:
npmprune "*.log" "*.bak"# Basic usage:
wget -qO- https://raw.githubusercontent.com/xthezealot/npmprune/master/npmprune.sh | sh
# With additional patterns:
wget -qO- https://raw.githubusercontent.com/xthezealot/npmprune/master/npmprune.sh | sh -s -- "*.log" "*.bak"# Basic usage:
RUN wget -qO- https://raw.githubusercontent.com/xthezealot/npmprune/master/npmprune.sh | sh
# With additional patterns:
RUN wget -qO- https://raw.githubusercontent.com/xthezealot/npmprune/master/npmprune.sh | sh -s -- "*.log" "*.bak"npmprune is compatible with both Linux and macOS environments, even with the most basic Alpine Linux setup.
