colejoffray / Stockify

1 stars 0 forks source link

Add `engines` to `package.json`, and potentially an`.nvmrc` file #2

Open nucleardreamer opened 7 months ago

nucleardreamer commented 7 months ago

So, one of the problems commonly with node projects is that you start on a specific version and everything is fine. As time goes by, dependancies get updated, you regenerate your package-lock.json or you add new things for a specific node version and stuff starts to break because the project was started on a specific version. It's generally a good idea to include an engines clause in the package.json file so that booting up the code from a fresh clone doesn't have problems. This is an example for LTS node as of this issue:

"engines": {
  "node": ">=18.19.x"
},

Also, it's generally a good idea to use nvm if you aren't already. It's very common to need a specific version of node for different projects - and this helps keep global installs in check as well. A lot of people like to write an .nvmrc file to their project with the current node version so that their current shell automatically switches to that version when they enter the directory. This is completely optional but a nice thing to add.

rjoffray commented 7 months ago

Here is a stackoverflow that discusses solutions to auto switch your node version by just switching to that folder

https://stackoverflow.com/questions/23556330/run-nvm-use-automatically-every-time-theres-a-nvmrc-file-on-the-directory

rjoffray commented 7 months ago

here is my bash_profile https://gist.github.com/rjoffray/d14076f7de6898333fd1a7e2c2ffc17d