2

When you work with two projects and one project depends on node v 8 and another one project depends on node v 10 you have to somehow switch between them.

  1. Not convenient way: This is not convenient because i have to always remember to type nvm use when i've just entered into root of project dir or when i've just opened new terminal session. So when you are working on some project you can go in to root dir and run nvm use and it'll pick up node version from your .nvmrc and you can work on this project in this terminal session. The same thing with another project - nvm use and work in this terminal session.

  2. Convenient but not reliable way: This is not way reliable because not all of devs have nvm exactly here $HOME/.nvm/nvm.sh and i don't like this hardcoding of nvm path because it's looks like some dirty hack. Follow answers in this thread and get some working way. This means that just for my personal local developing it will work(i've tried this thread and it's not working because of this error and i don't know what it means)

    $ source $HOME/.nvm/nvm.sh && nvm use && nodemon ts-node -r tsconfig-paths/register src/main.ts nvm is not compatible with the "PREFIX" environment variable: currently set to "/usr/local" Run unset PREFIX to unset it.

  3. Engines in package.json way

I've tried write "engines": {"node" : "10.14.1"}, in to my package.json but when i've started yarn - node haven't changed to 10.14.1(it's already installed on my laptop)

I don't know any more ways to conveniently and reliably change my node version just running yarn start. Do you know some way? Or may be you know some best practices?

Link
  • 669
  • 7
  • 20

1 Answers1

0

After some time i've reinstalled my OS and i've tried to use ZSH terminal. There is zsh-nvm plugin which check .nvmrc every time you do cd. Convenient. So good so far.

Link
  • 669
  • 7
  • 20