Today I Learned - Rocky Kev

TIL how to quickly create a .nvmrc file

POSTED ON:

TAGS:

In my job, we switch node versions a lot, using something like Node Version Manager to handle all the heavy lifting.

Which means, lots of weird hacks to figure out which node version is running in a specific project.

Weird hacks we've done:

  1. We tried to put the node version in the readme file. (Nobody ever reads it)

  2. We tried to lock down the node version in package.json (sometimes it works, sometimes it doesn't?)

  3. We start every project by going nvm i, which looks for a .nvmrc file. (BOOM! This works for unix devices! Windows... nah. See this convo)

To explain, your .nvmrc file saves your node version into the project. Node Version Manager finds that file, installs that version if it doesn't exist, and switches to that version. It's fantastic.

And to automatically generate that file: node -v > .nvmrc

That > is a bash command to send data from the left, to the riht.


Related TILs

Tagged:

TIL what is npm Script

Despite their high usage they are not particularly well optimized and add about 400ms of overhead. In this article we were able to bring that down to ~22ms.

TIL keywords in package.json

Today I learned what keywords are in a package.json file! It's a collection of keywords about a module. Keywords can help identify a package, related modules and software, and concepts.

TIL functional async/await

PLACEHOLDER