Today I Learned - Rocky Kev

TIL Node Version Manager

POSTED ON:

TAGS:

Ever clone a project and suddenly get a error when you build?
One thing to investigate is the node version.

For example:
Say the developer of this amazing animation library is using Node 13.5.0 while you're still on 10.16.3. Their code is definitely using the latest features for Node (or has a dependency that is using something important.)

But you have a legacy project that you've been managing on 10.16.3. It's still good, and doesn't need any bells or whistles. And upgrading to anything or higher causes it to fail.

Node Version Manager is perfect for this!

You can install nvm for windows, or nvm for linux/mac

Note: When you npm i, you are installing a bunch of packages based on the version of node you are currently using. If you're using 10.16.3 and npm i a project that's meant for node 13 or higher, you're going to have a bad time. Delete your node_modules and start over.


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 fancy methods to transform Javascript Objects

You can use Object.entries(), Object.keys(), Object.fromEntries()...

TIL how to hide your JS code

ONE THING TO NOTE: Encrypting a script is stronger than obfuscation, both methods are still not adequate to protect secret content. Honestly, I don't think it's worth it on a production site, and instead just go with pure server-side if you want security. But it's fascinating.