rubiin / npmprune

Prune unnecessary files from node_modules

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NPMprune

Fork of npmprune.sh with support for windows and added extras

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.

  1. Install
  2. Usage (Unix/Linux)
  3. Usage (Windows)
  4. Integration
  5. Compatibility

Install

wget -O /usr/local/bin/npmprune https://raw.githubusercontent.com/rubiin/npmprune/master/npmprune.sh

Usage (Unix/Linux)

  1. Ensure you have execution permissions: chmod +x npmprune.sh
  2. Run the script in your project directory: ./npmprune.sh

Usage (Windows)

  1. Open PowerShell.
  2. Navigate to your project directory.
  3. 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.

Production mode

If the NODE_ENV environment variable is set to production, NPMprune performs a more extensive cleanup by also removing type definitions.

Integration

In deployment scripts

wget -qO- https://raw.githubusercontent.com/rubiin/npmprune/master/npmprune.sh | sh

In a Dockerfile

RUN wget -qO- https://raw.githubusercontent.com/rubiin/npmprune/master/npmprune.sh | sh

Compatibility

NPMprune is compatible with Windows, Linux and macOS environments, even with the most basic Alpine Linux setup.

About

Prune unnecessary files from node_modules


Languages

Language:PowerShell 55.3%Language:Shell 44.7%