Skip to content

Tired of dealing with those pesky 'node_modules' cluttering up your project? Get the Zsh plugin that keeps your workspace squeaky clean!

License

Notifications You must be signed in to change notification settings

nicolodiamante/nodo

Repository files navigation

nodo

Node_modules directory is an essential component of Node.js projects, but it can often become a nuisance when it takes up too much disk or cloud storage space. It is not uncommon for node_modules directories to contain thousands or even millions of files. This can be a problem for inactive projects, as the folder can occupy valuable storage space. One might wonder why they would want to keep such large node_modules folders for inactive projects when package.json can recreate them anytime.

Fortunately, there is a solution to this problem. If you're working on a Mac, iCloud runs in the background and can sync files across devices. However, this can fill up your iCloud storage quickly. To prevent this, you can use the nodo utility. It helps to un-sync the node_modules directory and save space by removing all node_modules directories within the chosen root directory. This is particularly useful for cleaning up a project that has multiple node_modules trees. By using this utility, you can free up valuable storage space and optimise your project.

Getting Started

Here are the two methods you can choose from:

Automatic Download via curl: Simply execute the following command in your terminal to quickly download and seamlessly install the utility:

zsh -c "$(curl -fsSL https://raw.githubusercontent.com/nicolodiamante/nodo/HEAD/bootstrap.zsh)"

Manual Cloning: For those who prefer a hands-on approach, you can manually clone the repository to your desired location:

git clone https://github.com/nicolodiamante/nodo.git ~/nodo

Post-Download Steps

Directory Navigation & Script Execution: Navigate to the root directory of the repository, and then execute the installation script using the following command:

source utils/install.zsh

Nodo Configuration: This script aims to locate the zshrc file, then appends the path nodo/script to the fpath variable.

fpath=(~/nodo/script $fpath)
autoload -Uz nodo

Install via Oh My Zsh

If you're using Oh My Zsh, you can install nodo as a plugin:

git clone https://github.com/nicolodiamante/nodo.git $ZSH_CUSTOM/plugins/nodo

Then, add nodo to your .zshrc plugins array:

plugins=(... nodo)

Restart theshell to activate the changes.

How to use nodo

nodo [option]

Options:

  • --nosync: Stop the sync of the node_modules directory into iCloud.
  • --remove: Remove the node_modules directory within the chosen root directory.

For a comprehensive list of options and functionalities, use: nodo --help.

Notes

When nodo is launched inside a Git repository, it will search for the .gitignore file. If it does not find it, it will create it. If it does find it, nodo will append node_modules to the existing .gitignore file. This ensures that the node_modules directory will be ignored by Git and will not be included in future commits, further optimising the project and saving valuable storage space.


Resources

Contribution

Any suggestions or feedback you may have for improvement are welcome. If you encounter any issues or bugs, please report them to the issues page.

Nicolò Diamante Portfolio

MIT License