Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 608
k0pernikus Avatar asked Aug 15 '17 09:08

k0pernikus


2 Answers

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. 
like image 107
k0pernikus Avatar answered Sep 20 '22 13:09

k0pernikus


I was getting the following warning along with some other licensing warnings.

warning package.json: No license field warning [email protected]: No license field 

All I did was, update the package.json file's private property to be true.

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

With this, I no longer got any No license field warnings when I do yarn install. To understand why, please see this question.

{"private": true} means, that npm will refuse to publish it, to prevent accidental publication of private repositories.

For more on this, see the following links. https://docs.npmjs.com/files/package.json#private https://flaviocopes.com/package-json/#private

like image 21
Keet Sugathadasa Avatar answered Sep 18 '22 13:09

Keet Sugathadasa