Remove unnecessary files from node_modules (.md, .ts, ...)

Overview

What?

node-prune is a small tool to prune unnecessary files from ./node_modules, such as markdown, typescript source files, and so on. Primarily built for Up which lets you deploy serverless web applications in seconds.

Installation

From gobinaries.com:

$ curl -sf https://gobinaries.com/tj/node-prune | sh

From source:

$ go get github.com/tj/node-prune

Usage

In your app directory:

$ node-prune

files total 27,330
files removed 3,990
size removed 13 MB
   duration 200ms

Somewhere else:

$ node-prune path/to/node_modules

files total 27,330
files removed 3,990
size removed 13 MB
   duration 200ms

Or add to the package.json scripts field

  "scripts": {
    "postinstall": "node-prune"
  }

Why?

huge


GoDoc

Comments
  • Do not prune *.d.ts files

    Do not prune *.d.ts files

    Fixes https://github.com/tj/node-prune/issues/65

    Files matching the regex "*.d.ts" will not be removed from node_modules.

    Up until now, this library hasn't done two things: used regex anywhere or had exceptions to the default rules. This largely makes sense, as the current whitelisted dirs/files/extensions can be put into maps with O(1) lookup times.

    This PR adds regex based exceptions, which cannot be put into a map, so the time complexity will be O(nm) where n is the number of regexes we whitelist as exceptions, and m is the time complexity to compute the regex.

    I am going to argue that as long as the regex list is kept small (which I put in a comment in the code) that the practical time difference will be minimal.

    Here is me running my forked tool over a 1.4GB monorepo: Screen Shot 2020-05-04 at 11 22 33 AM

    And here is a run over the same 1.4GB node_modules using the tool at HEAD: Screen Shot 2020-05-04 at 11 29 28 AM

    On repeated runs, they seem to execute in roughly the same time frame, so the performance impact of this PR seems negligible.

    opened by dmattia 11
  • node-prune commando not found with go path set

    node-prune commando not found with go path set

    Hi TJ, I have installed already go and I export the path to, go bin but node prune isn't on my shell yet.

    export PATH=$PATH:$GOROOT/bin:$GOPATH/bin 
    

    so what more I have to do?

    Thanks.

    opened by alesanabriav 6
  • Error on instalation

    Error on instalation

    I love the idea from the project! I'm trying to install it and is returning error :(

    $ go get -u github.com/tj/node-prune/cmd/node-prune
    
    src/github.com/tj/node-prune/cmd/node-prune/main.go:50: time.Since(start).Round undefined (type time.Duration has no field or method Round)
    
    opened by raphamorim 5
  • cannot install

    cannot install

    I am installing from root directory.Using provided command: go get github.com/tj/node-prune/cmd/node-prune

    It gives me this error: go/src/github.com/tj/node-prune/cmd/node-prune/main.go:50: time.Since(start).Round undefined (type time.Duration has no field or method Round)

    opened by worst-developer 4
  • feat: Support match file with regular expression

    feat: Support match file with regular expression

    Here is the default regExp

    // Default pruned which match regular expression
    var DefaultRegExp = []string{
    	`\.___jb_tmp___$`,  // generate by JetBrains ide, to detect the file change
    }
    
    opened by axetroy 3
  • node-prune: line 1: syntax error: unexpected newline

    node-prune: line 1: syntax error: unexpected newline

    Installing in alpine docker with:

    $ curl -sL https://github.com/tj/node-prune/releases/download/v1.0.0/node-prune_1.0.0_linux_amd64.tar.gz \
    >       | tar xzvf - -C /tmp
    

    and running:

    $ node-prune /usr/local/lib/node_modules/
    
    /usr/bin/node-prune: line 1: syntax error: unexpected newline
    
    opened by blacktop 3
  • go get fails on go 1.7 - type time.Duration has no field or method Round)

    go get fails on go 1.7 - type time.Duration has no field or method Round)

    I can go get this fine on my Arch distro, but on my Win10 box, it fails:

    ~> go get github.com/tj/node-prune/cmd/node-prune
    # github.com/tj/node-prune/cmd/node-prune
    dev\golang\src\github.com\tj\node-prune\cmd\node-prune\main.go:50: time.Since(start).Round undefined (type time.Duration has no field or method Round)
    
    opened by klauern 3
  • Add missing comma on Default files declaration

    Add missing comma on Default files declaration

    We encountered an error in your latest update.

    You missed a , in the prune.go file which is causing the installation of your library to fail. This is the error:

    /go/src/github.com/tj/node-prune/prune.go:42:10: syntax error: unexpected newline, expecting comma or }
    
    opened by FLarra 2
  • Update README.md with logo image

    Update README.md with logo image

    • The README file has been renamed to take the more conventional uppercase name.
    • The node prune image is now served up from the local repository so if the external source ever goes down, the image will still display on the README page.
    • The height has been fixed to not be so dynamic.

    Addresses: #38

    opened by oshalygin 2
  • hi we are the Lucy's

    hi we are the Lucy's

    hi node-prune how are you ? as you can see by the title we are the lucy's we are extremely advanced coders and we want to get our github and our wiki page out there so we are trying to make friends with some fellow coders. we just have a couple of questions to aks if thats ok? such what is forking? becuse we accindently forked you. get back to us as soon as you can looking forward to hearing from you love from the lucy's xoxo

    opened by LUCYISCOOL 2
  • Error while installing

    Error while installing

    Node.js version: v0.10.25 Go version: go1.8.3 linux/amd64

    # github.com/tj/node-prune/cmd/node-prune
    /home/sam3/go/src/github.com/tj/node-prune/cmd/node-prune/main.go:50: time.Since(start).Round undefined (type time.Duration has no field or method Round)
    
    opened by souri 2
  • Support for armv7l

    Support for armv7l

    Currently https://gobinaries.com/tj/node-prune fails on 32bit Raspberry PI / also in linux/arm Docker containers:

    $ uname -m
    armv7l
    $ curl -sf https://gobinaries.com/tj/node-prune | sh
    
      ==> Downloading github.com/tj/node-prune@master
      ==> Resolved version master to v1.2.0
      ==> Downloading binary for linux armv7
    
      Error downloading, got 500 response from server
    

    I found that using "arch=arm" does work, but this workaround is a bit ugly in Dockerfiles:

    RUN curl -w %{http_code} -sL -o /usr/local/bin/node-prune "https://gobinaries.com/binary/github.com/tj/node-prune?os=linux&arch=arm&version=v1.2.0" && chmod +x /usr/local/bin/node-prune
    
    opened by int0x27 0
  • After node-prune ember.js does not start!

    After node-prune ember.js does not start!

    yarn run v1.22.4
    $ ember serve
    Cannot read property 'jobs' of undefined
    
    
    Stack Trace and Error Report: /var/folders/f0/c6hyjkv52qzgm01qjspmhlqr0000gn/T/error.dump.8376839b067563a302c7c409201eebdf.log
    error Command failed with exit code 1.
    

    Full trace:

    =================================================================================
    
    ENV Summary:
    
      TIME: Sat Jun 20 2020 17:22:06 GMT-0300 (Brasilia Standard Time)
      TITLE: ember
      ARGV:
      - /Users/bruno/.nvm/versions/node/v13.14.0/bin/node
      - /Users/bruno/develop/dash/node_modules/.bin/ember
      - serve
      EXEC_PATH: /Users/bruno/.nvm/versions/node/v13.14.0/bin/node
      TMPDIR: /var/folders/f0/c6hyjkv52qzgm01qjspmhlqr0000gn/T
      SHELL: /bin/zsh
      PATH:
      - /var/folders/f0/c6hyjkv52qzgm01qjspmhlqr0000gn/T/yarn--1592684521607-0.7071375003663911
      - /Users/bruno/develop/dash/node_modules/.bin
      - /Users/bruno/.config/yarn/link/node_modules/.bin
      - /Users/bruno/.nvm/versions/node/v13.14.0/libexec/lib/node_modules/npm/bin/node-gyp-bin
      - /Users/bruno/.nvm/versions/node/v13.14.0/lib/node_modules/npm/bin/node-gyp-bin
      - /Users/bruno/.nvm/versions/node/v13.14.0/bin/node_modules/npm/bin/node-gyp-bin
      - /usr/local/opt/libpq/bin
      - /Users/bruno/.gem/ruby/2.6.0/bin
      - /Users/bruno/.krew/bin
      - /Users/bruno/.yarn/bin
      - /Users/bruno/.config/yarn/global/node_modules/.bin
      - /Users/bruno/bin
      - /usr/local/bin
      - /usr/local/opt/libpq/bin
      - /Users/bruno/.gem/ruby/2.6.0/bin
      - /Users/bruno/.krew/bin
      - /Users/bruno/.yarn/bin
      - /Users/bruno/.config/yarn/global/node_modules/.bin
      - /Users/bruno/.nvm/versions/node/v13.14.0/bin
      - /Users/bruno/bin
      - /usr/local/bin
      - /usr/local/bin
      - /usr/bin
      - /bin
      - /usr/sbin
      - /sbin
      PLATFORM: darwin x64
      FREEMEM: 811073536
      TOTALMEM: 17179869184
      UPTIME: 838299
      LOADAVG: 6.365234375,3.96875,3.0322265625
      CPUS:
      - Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz - 2700
      - Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz - 2700
      - Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz - 2700
      - Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz - 2700
      - Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz - 2700
      - Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz - 2700
      - Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz - 2700
      - Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz - 2700
      ENDIANNESS: LE
      VERSIONS:
      - ares: 1.16.0
      - brotli: 1.0.7
      - cldr: 36.1
      - icu: 66.1
      - llhttp: 2.0.4
      - modules: 79
      - napi: 6
      - nghttp2: 1.40.0
      - node: 13.14.0
      - openssl: 1.1.1g
      - tz: 2019c
      - unicode: 13.0
      - uv: 1.37.0
      - v8: 7.9.317.25-node.32
      - zlib: 1.2.11
    
    ERROR Summary:
    
      - broccoliBuilderErrorStack: [undefined]
      - code: [undefined]
      - codeFrame: [undefined]
      - errorMessage: Cannot read property 'jobs' of undefined
      - errorType: [undefined]
      - location:
        - column: [undefined]
        - file: [undefined]
        - line: [undefined]
      - message: Cannot read property 'jobs' of undefined
      - name: TypeError
      - nodeAnnotation: [undefined]
      - nodeName: [undefined]
      - originalErrorMessage: [undefined]
      - stack: TypeError: Cannot read property 'jobs' of undefined
        at Object.<anonymous> (/Users/bruno/develop/dash/node_modules/ember-cli/lib/utilities/platform-checker.js:10:24)
        at Module._compile (internal/modules/cjs/loader.js:1118:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10)
        at Module.load (internal/modules/cjs/loader.js:982:32)
        at Function.Module._load (internal/modules/cjs/loader.js:875:14)
        at Module.require (internal/modules/cjs/loader.js:1022:19)
        at require (internal/modules/cjs/helpers.js:72:18)
        at CLI.run (/Users/bruno/develop/dash/node_modules/ember-cli/lib/cli/cli.js:154:31)
        at processTicksAndRejections (internal/process/task_queues.js:97:5)
        at async module.exports (/Users/bruno/develop/dash/node_modules/ember-cli/lib/cli/index.js:147:12)
    
    =================================================================================
    
    
    opened by brunoocasali 0
  • Add compile files

    Add compile files

    What does this PR do

    Remove files needed to compile native add-ons (.cpp, .h, .o etc) Remove the package-lock.json since it's not needed anymore after installing dependencies. Remove man directory (man pages), features (cucumber) and .git

    opened by Aschen 2
  • install.goreleaser.com integration broken

    install.goreleaser.com integration broken

    Just a heads up. The removal the of the goreleaser.yaml in this commit https://github.com/tj/node-prune/commit/330b83e1fc4963b28206894403abcd3d604b84a3 broke the CI build over at https://travis-ci.org/github/goreleaser/godownloader/jobs/687930154

    To fix the build over there I've submitted a PR to remove node-prune from the goreleaser repo: https://github.com/goreleaser/godownloader/pull/176

    opened by joemiller 0
Releases(v1.0.1)
Owner
TJ Holowaychuk
TJ Holowaychuk
Pack all your node_modules and other files you want inside your project to a zip file.

?? Node Modules Packer Use Cases | Usage | Examples | Headless | Benchmarks | Reference This is a library to package all your node_modules and other f

Vinicius Lourenço 14 Dec 1, 2022
2x times faster than chalk and use 5x less space in node_modules

Nano Colors A tiny and fast Node.js library for formatting terminal text with ANSI colors. It is 2 times faster than chalk. Both loading and calls. No

Andrey Sitnik 886 Dec 30, 2022
Trim unnecessary indentation when pasting code

Unindent When pasting code from your editor into Discord, it often ends up having a lot of indentation. This plugin fixes that by trimming unnecessary

Vens Powercord Plugins 19 May 1, 2022
Trims unnecessary whitespace from your Obsidian documents.

Trim Whitespace Trim Whitespace trims unnecessary blank characters from your Obsidian documents. This is a common feature in code editing software, an

Zack Lovatt 18 Dec 13, 2022
Smooth scrolling effect (while using mouse wheel). No jQuery or other unnecessary stuff needed.

scrooth Smooth scrolling effect (while using mouse wheel). No jQuery or other unnecessary stuff needed. Why? I needed that, and I was unable to find p

Rafał Spiżewski 20 Aug 29, 2022
Microverse Module 02 Project: This is an educational project to make a TodoList web application, where the users can add new todo, remove todo, edit todo, mark todo as completed, and remove all completed todo. Built with Webpack

todo-list This project is about building a list of To Do tasks. Where you can save your daily activities and help in daily evaluation. Live demo you v

divine charlotte 25 Jan 3, 2023
Aron 8 Dec 17, 2022
Piplup: decompile Playdate Pulp .pdx files back to .json project files

Piplup: decompile Playdate Pulp .pdx files back to .json project files This doesn't work yet: I still need to: convert the graphics (.pdt files) back

null 6 Mar 25, 2022
🌸 A cli can automatically generate files from Excel files.

unxlsx A cli can automatically generate files from Excel files. Why We often need to export some information from XLSX to generate our files, such as

Frozen FIsh 24 Aug 22, 2022
JavaScript library for parsing Dirtywave M8 files, complete with a CLI for interacting with M8 files.

m8-js This repository contains a JavaScript library for parsing Dirtywave M8 files, as well as a CLI for interacting with M8 files. The hopes are not

Jeremy Whitlock 20 Dec 17, 2022
Download all Moodle files with one click. This is a Chrome extension built to save time and effort from downloading files manually one by one!

Moodle Downloader Extension Moodle downloader extension for Chrome. The extension is tested with both the TUM moodle and the official moodle demo. Not

Zhongpin Wang 8 Nov 15, 2022
Vaultacks lets users store files off-chain on Gaia. Files are encrypted by default but also can be made public and shared

Vaultacks Vaultacks is built on the Stacks Chain. It lets users upload files to Gaia, a off-chain data storage system. Vaultacks currently uses the de

Anish De 5 Sep 14, 2022
Obsidian plugin that allows user to create a glossary of files, an index of files or both.

Obsidian Auto Glossary Auto Glossary is an Obsidian plugin to create a glossary, an index or a glossary with an index from the files you want. Feature

Ennio Italiano 29 Dec 30, 2022
This is an imitation of the Amazon online shopping store. Users can add and remove items from the cart, proceed to checkout and make payments.

AMAZON This is an imitation of the Amazon online shopping store. Users can add and remove items from the cart, proceed to checkout and make payments.

Kevv_in 7 Mar 23, 2022
Polyfill to remove click delays on browsers with touch UIs

FastClick FastClick is a simple, easy-to-use library for eliminating the 300ms delay between a physical tap and the firing of a click event on mobile

FT Labs 18.8k Jan 2, 2023
A simple to do list webpage where you can log the daily tasks you have to do, mark them as checked, modify them, reorder them and remove them. Made using HTML, CSS and JavaScript.

To-Do-List This Webpage is for an app called To-Do-List which helps you add, remove or check tasks you have to do. It is a simple web page which conta

Zeeshan Haider 9 Mar 12, 2022
Awesome books is a simple website that displays a list of books and allows you to add and remove books from that list

Awesome books is a simple website that displays a list of books and allows you to add and remove books from that list. By building this application, you will learn how to manage data using JavaScript. Thanks to that your website will be more interactive. built with modern JavaScript and uses SPA technology.

Aniekan udo 9 Mar 29, 2022
This "To-do-list" app is a simple web application that displays a list of task and allows you to add and remove task from that list. it is built with the latest technology namely; JavaScript with webpack Configuration.

To-do-list "To-do-list" is a simple web application that displays a list of task and allows you to add and remove task from that list. Built With HTML

Aniekan udo 10 Nov 21, 2022
This extensions will prompt you to remove any other extensions that we found as being broken and unmaintained.

octarine vscode extension This extensions will prompt you to remove any other extensions that we found as being broken and unmaintained. We do expect

42picky 4 May 27, 2022