Search code examples
javascriptnode.jsreactjsyarnpkgpackage.json

Why does "No license field" Warning Disappear when you set "private": true in your package.json


I have a react application that installs its dependencies via yarn install. When I run this command, I get the following No license field related warnings.

warning package.json: No license field
warning react-material-dashboard@0.3.0: No license field

Then I updated, the package.json file's private property to be true. (See NPM docs)

{
  "name": "some-application-name",
  "author": "Keet Sugathadasa",
  "email": "email",
  "license": "MIT",
  "version": "0.0.1",
  "private": true,
  ...
}

Now, all warnings related to No license field disappeared. Why?


Solution

  • The warning complains about there not being a license field (with an s), you do however have a licence field (with a c), correct the spelling and the warning should disappear.

    The reason that setting "private": true works and prevents the warning from appearing is that private packages don't get distibuted and therefore do not need a license.