auto-set-node-version
automatically set node version...
- an example code is provided in below section for ease.
- When you run npm-script (example taken for
npm start
), - it reads
package.json
for the node version required for your project, - and, switches the node version.
- Note: Assuming, you are using
nvm
for using different node versions.
How to use / consume this npm-package
$ npm install auto-set-node-version@1.0.3 --save-dev
- Update your project's
package.json
file:
"scripts": {
"prestart": "npm run set-node",
"start": "node -e \"console.log('%s: Define your task (npm start).', Date())\" && exit 1",
"set-node": "node ./node_modules/auto-set-node-version/index.js"
}
"devDependencies": {
"auto-set-node-version": "^1.0.3"
},
"engines": {
"node": ">=12.14.1"
},
- Done!
Compatibility:
-
Windows
: tested & works well. -
*nix
: NOT supported. Reason: executing nvm as a command in child process doesn't work as it's not a terminal-command (it runs as shell-function).