Saturday, April 1, 2017

What is a yarn.lock file?

yarn.lock is a file like package.json. It probably sits in the same folder if it exists. It's optional so it might not be there at all. If it is there you may use the command...

yarn install

 
 

...to use it to hydrate a "node_modules" folder in lieu of...

npm install

 
 

...which uses package.json instead of yarn.lock for the "What do I do?" instructions. Why should you care? yarn.lock locks dependencies at very specific versions and thus ensures that when you pull the dependencies there won't be some new version of something that introduces breaking changes which is a cornerstone of grievances against NuGet and npm and all other dependency management "You don't have to worry about it" hogwash. Could you just lock in specific versions with NuGet and npm and other tools? Sure! But, by convention no one does. It's npm convention to have carats and tildes sprinkled about your package.json file. And so, just as we use LinkedIn by convention for something a bit different than we use Facebook even though the two are basically the same app, so too may we use Yarn a bit differently than npm even though they sure seem similar. Get yarn here. Afterwards, open a command prompt and type...

yarn --version

 
 

...to make sure it's there. I got 0.21.3 back when I did this. This has a cheatsheet of commands like "yarn install" and I had to go there in order to set up the seed for the Clarity Controls and get the app to run at localhost:4200 without breaking. When I complained at GitHub about "npm install" not working I was just told to use Yarn.

No comments:

Post a Comment