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.