2

Background

  • I want to make sure that no matter the machine (non-windows) that runs my project it will always run with the same, controlled, version of Node.js.
  • I currently use npm scripts for my build, as seen here.
  • I want to be able to update and control that version of Node.js, preferably from my package.json.
  • I think, but I'm really not at all sure, that nvm is the tool to solve this.
  • I've looked into a few resources on nvm without reaching the understanding I need of nvm to do what I want to. (which may be due to using the wrong tool for my purposes?)

The Question

What kind of script could I write that would make sure the node version that the remainder of my scripts was run by would be the node version I want?

OR

What tool should I be using instead of nvm? And is there a convenient guide to how to use it for my use case?

Dream Example

What I hope to do would look something like...

"dev":"nvm *Do stuffs?* && npm run restOfDev",
Suni
  • 633
  • 8
  • 16
  • Possible duplicate of [Is there any way how to run "nvm use" automatically in "prestart" npm script?](https://stackoverflow.com/questions/34301122/is-there-any-way-how-to-run-nvm-use-automatically-in-prestart-npm-script) – c24w Sep 04 '17 at 10:19

1 Answers1

-1

I do not know if it's related to what you want, but yarn is very useful to live with problems with package versions. Keeps the package versions in the yarn.lock file.

Ahmet Şimşek
  • 1,391
  • 1
  • 14
  • 24
  • We're using yarn for that actually. And I'm very happy with it's performance! I just haven't found a way to use it to lock down node itself yet. Are you using it for that as well? – Suni Mar 03 '17 at 16:17