Giter VIP home page Giter VIP logo

nvm-auto's Introduction

nvm-auto

nvm-auto is an plugin for the venerable oh-my-zsh.

It aims to alleviate needing to type nvm use as much as possible, especially if you often switch between versions of node.js and use .nvmrc files in your project to manage what version of node your project needs.

The Problem

Let's say for example that you have the following directory structure with 2 projects in it:

~
+-- Project1
|   +--- .nvmrc
|
+-- Project2   
    +--- .nvmrc

Let's say Project1's .nvmrc file states we need node v4.2.4. Project2's, on the other hand, states a need for v5.8.0.

To move between projects you will need to do something like:

cd Project1
nvm use

// do some stuff in project one

cd Project2
nvm use

//do some other stuff

If you are like me, you often forget to execute the nvm use commands after each cd. This can lead to problems ranging from the simple scripts not running to more problematic ones like global npm installs against the wrong node version, or bad module builds for the local repo.

How nvm-auto helps

If you use oh-my-zsh, then this plugin helps by auto-executing the nvm use command when you switch contexts (for example from Project1 to Project2).

No more bad installs, no more cluttering up the global node area with unneeded modules.

Installation

For the impatient:

cd ~/.oh-my-zsh/custom/plugins
git clone https://github.com/dijitalmunky/nvm-auto.git
sed -e 's/^plugins=(\(.*\))/plugins=(\1 nvm-auto)/' -i .pre-nvm-auto ~/.zshrc
echo 'nvm_auto_switch' >> ~/.zshrc
source ~/.zshrc

For the less impatient:

  1. Ensure you have nvm >=0.30 installed properly.

  2. Make sure you have set the default alias for nvm - e.g.: nvm set default 5.9.0

  3. Have oh-my-zsh installed (D'uh!)

  4. Open a terminal and navigate to your ~/.oh-my-zsh/custom/plugins folder.

  5. Clone this repository to that folder.

  6. Add nvm-auto to your plugins variable in ~/.zshrc.

  7. Add a call to the nvm_auto-switch function after NVM is initialized in your .zshrc file.

  8. Source .zshrc in your current shell or restart your shell.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.