Tip #1 – Unlicensed npm packages

Every day is a learning experience for me, so I’ve decided to keep a log of very short tips on this blog for things that I discover here and there. I frequently stumble across little quirks and details in software that I want to talk about but aren’t deserving of traditional posts or deep dives. Plus, I don’t enjoy writing long pieces about mundane things. Win-win!

Today’s tip relates to Node.js, or, more precisely, package managers like npm and yarn.

Use the word UNLICENSED in the license field of your package.json file when you don’t have an explicit license for your codebase. This is an officially supported feature in both npm and yarn. See the following example:

{
  "name": "my-package",
  "version": "1.0.0",
  "description": "This is what my package does",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/username/my-package.git"
  },
  "author": {
    "name": "Awesome Person",
    "email": "awesomeperson@hotmail.com",
    "url": "https://awesomeperson.info"
  },
  "license": "UNLICENSED",
  "bugs": {
    "url": "https://github.com/username/my-package/issues"
  },
  "homepage": "https://github.com/username/my-package#readme"
}

Note: Please do not confuse this with another supported value, Unlicense, which is the official SPDX identifier for the Unlicense, a public domain dedication document.

Leave a Reply

Your email address will not be published. Required fields are marked *