Skip to content

Instantly share code, notes, and snippets.

@tichopad
Last active September 19, 2022 08:09
Show Gist options
  • Save tichopad/42b5118ab25a4871b83181889179fbd9 to your computer and use it in GitHub Desktop.
Save tichopad/42b5118ab25a4871b83181889179fbd9 to your computer and use it in GitHub Desktop.
Run arbitrary Node version via Docker
#!/bin/bash
# Example runs: `nv 17 ./script.js`, `nv latest yarn install`
# Get Node version
VERSION=$1
# Get the rest of the arguments
shift
ARGUMENTS=$@
docker run \
--interactive \
--network host \
--rm \
--tty \
--user $(id -u):$(id -g) \
--volume $(pwd):/usr/src/app \
--workdir /usr/src/app \
node:$VERSION $ARGUMENTS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment