Last active
September 27, 2022 21:38
-
-
Save blizzz/0bb7e2e617742dcc5cbaf7b7216062f4 to your computer and use it in GitHub Desktop.
Execute a command with the node and npm version as required in package.json (on arch)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env bash | |
# requires nvm installed from AUR (i.e. only tested on Arch), and also jq | |
# run from the project directory like: runWithNodeAndNpm.sh make dev-setup | |
# the package.json is taken from the current working directory | |
NODE_MAJOR_VERSION=$(cat package.json | jq .engines.node | grep -oE '[0-9]*' | head -1) | |
NPM_MAJOR_VERSION=$(cat package.json | jq .engines.npm | grep -oE '[0-9]*' | head -1) | |
source /usr/share/nvm/init-nvm.sh | |
nvm install ${NODE_MAJOR_VERSION} && \ | |
npm install -g npm@${NPM_MAJOR_VERSION} && \ | |
${@} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment