Some OSS projects have a README that says what version of Node to download and what version of npm/yarn/pnpm/etc. to use.
Some projects have no information and leave you to guess.
This project is inspired by Gradle’s Wrapper.
-
Download
.ntw.sh
to your project’s root directory. -
Create a
yarnw
script that looks like this:#!/bin/bash . .ntw.sh selectNode v16.13.1 selectTool yarn 1.22.17 exec yarn "$@"
This will download the chosen node for your platform. Then it will download yarn the version of yarn you choose.
./yarnw
will function exactly likeyarn
.Optionally, you can add this before sourcing
.ntw.sh
if you have a corporate proxy.export NTW_NODE_DIST_URL=https://artifactory.mycompany.comp/nodejs-dist
You can check in
yarnw
and.ntw.sh
to your VCS.curl -sL https://raw.githubusercontent.com/rahulsom/node-tool-wrapper/main/.ntw.sh -o .ntw.sh curl -sL https://raw.githubusercontent.com/rahulsom/node-tool-wrapper/main/yarnw -o yarnw chmod +x .ntw.sh yarnw