How to have yarn not issue a warning for the license field?

k0pernikus picture k0pernikus · Aug 15, 2017 · Viewed 32.9k times · Source

On running yarn install I see a warning every time that there is no license filed even though I have defined one:

$ jq . package.json 
{
  "name": "license-example",
  "version": "1.0.0",
  "main": "index.js",
  "license": "UNLICENSED",
  "dependencies": {
    "lodash": "^4.17.4",
    "moment": "^2.18.1"
  }
}

which according to the npm defintion should be valid:

Finally, if you do not wish to grant others the right to use a private or unpublished package under any terms:

{ "license": "UNLICENSED" }

Here's the output:

yarn install
yarn install v0.27.5
warning ../package.json: No license field
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.09s.

My main goal is for that warning to disappear, yet I also don't want to provide an invalid open-source LICENSE to make the warning go away, even if it is an internal project that never will be seen on the outside.

How to mark a yarn project as proprietary without a warning appearing?

Answer

k0pernikus picture k0pernikus · Aug 15, 2017

For yarn and npm, the default behavior is that they look up into the parent directories.

I had an outdated and forgotten package.json in my home folder without a license field:

~/package.json

When running yarn install within my project:

~/my-project/package.json

yarn then also found the one in my home directory and reported the error for that one. I mistook that for my project's package.json.

The warning makes that clear by preceding the path with .. for the parent folder.

warning ../package.json: No license field

After removing that outdated package.json I get the expected output:

yarn install v0.27.5
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.88s.