Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rubiin/npmprune
Prune unnecessary files from node_modules
https://github.com/rubiin/npmprune
Last synced: about 1 month ago
JSON representation
Prune unnecessary files from node_modules
- Host: GitHub
- URL: https://github.com/rubiin/npmprune
- Owner: rubiin
- Created: 2023-12-29T04:45:49.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2024-06-26T18:12:05.000Z (5 months ago)
- Last Synced: 2024-06-26T22:36:16.909Z (5 months ago)
- Language: PowerShell
- Homepage:
- Size: 4.88 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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](#install)
2. [Usage (Unix/Linux)](#usage-linux)
3. [Usage (Windows)](#usage-windows)
4. [Integration](#integration)
- [In deployment scripts](#in-deployment-scripts)
- [In a Dockerfile](#in-a-dockerfile)
5. [Compatibility](#compatibility)## Install
```sh
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
```sh
wget -qO- https://raw.githubusercontent.com/rubiin/npmprune/master/npmprune.sh | sh
```### In a Dockerfile
```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.