NPM License Checker
This post is in relation to the previous post regarding software licensing. We understood that in most of the cases we need to attribute the derivative product to the creators of these libraries as well. I think it should be done morally first and then legally as well. After all, these libraries have saved so much of dev time that goes into reinventing the wheel.
If you think of the average time required to create any NodeJS library that has >1k lines of code - it is huge. The code is well thought of and validated by it’s users as well it reduces your worry as a developer. In the NodeJS ecosystem, products tend to make use of many of these. In fact this is what reduces the development time of the end product drastically.
When it’s time to ship the product to the customer, it is also time to revisit the list of dependencies using which you have created the beauty and/or the beast! A lot of npm packages are used for building the product in NodeJS. It is true for other languages as well, but today we talk about NodeJS and specifically the npm package
License Checker comes in very handy when you have to get the list of licenses used in all the
node_modules as part of your application. Can you count the number of packages in one of your NodeJS applications for me, please? Without
license-checker all you have to do is open every module folder - find the
LICENSE file - open the file to see which type of license it is - make a note of it and close the file - repeat the process for all the modules in
node_modules folder. Below image shows an example
moment module installed within
Trust me, that process is really tedious and a total waste of time especially when you have something like
license-checker does the same in the matter of seconds and you don’t have to use your brain either. All you need is simple
npm cli skills to run a couple of commands. Just install
license-checker globally and run
license-checker --json > licenses.json in the root folder of the application directory. Almost instantly you will have a well formatted
json file available with the list of all the licenses used till now. Of course, you have several other options to do the same and can be found in their documentation.
This information comes in very handy during the packaging phase of the product or application, before shipping it.