menu

Questions & Answers

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?

Comments:
2023-01-19 23:10:16
Because a private package will not be distributed and therefore doesn't need a license!
2023-01-19 23:10:16
Also, you spelled license incorrectly. It's license with an s not licence with a c
2023-01-19 23:10:16
@phuzi, Updated license. Thanks. I think you answered my question. If you can post it as an answer with a description, to help others as well. I can accept it.
2023-01-19 23:10:16
For what it's worth, react-material-dashboard@0.3.0 didn't declare any license in package.json (current version does).
Answers(2) :

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.

Comments:
2023-01-19 23:10:16
Spelling mistake fixed it. And thanks for sharing that license field is ignored when "private": true.

UPDATED: FIXED - CD into the right directory, I was in the parent directory

Old issue:

This did not resolve my issue, in the terminal I see:

homefolder@MacBook-Pro LFHome % yarn start
yarn run v1.22.19
warning package.json: No license field
error Command "start" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
homefolder@MacBook-Pro LFHome % 

Even though I changed the package.json to:

{
  "name": "seventhave",
  "email": "email",
  "licence": "MIT",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@fortawesome/fontawesome-svg-core": "^6.2.1",
    "@fortawesome/free-solid-svg-icons": "^6.2.1",
    "@fortawesome/react-fontawesome": "^0.2.0",
    "@testing-library/jest-dom": "^5.16.5",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-scripts": "5.0.1",
    "web-vitals": "^2.1.4"
  },