Skip to content

Instantly share code, notes, and snippets.

@libertylocked
Last active August 14, 2018 16:46
Show Gist options
  • Save libertylocked/7f606b59ca36eb5b92c961018d86db61 to your computer and use it in GitHub Desktop.
Save libertylocked/7f606b59ca36eb5b92c961018d86db61 to your computer and use it in GitHub Desktop.
npm-nvm.sh - run npm using a node version specified in nvmrc.
#!/bin/sh
# This script runs NPM using a version of node specified in nvmrc
# npm-nvm.sh <command>
# Examples:
# - npm-nvm.sh install
# - npm-nvm.sh run build
NPM_PREFIX=$(npm config get prefix)
npm config delete prefix
source /usr/share/nvm/init-nvm.sh --install && \
nvm install && \
nvm use --delete-prefix && \
npm $@ && \
nvm unalias default
npm config set prefix ${NPM_PREFIX}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment