Ionică Bizău
Ionică Bizău

Reputation: 113465

Custom license url in package.json

I'm interested to know if there is a way for passing custom license urls in NPM's package.json files.

I tried:

{
  "license": {"name": "foo", "url": "http://example.com" }
}

It seems that this format is now deprecated:

// Not valid metadata
{ "license" :
  { "type" : "ISC"
  , "url" : "http://opensource.org/licenses/ISC"
  }
}

Is there another way to pass the license url in package.json?

Upvotes: 1

Views: 2689

Answers (3)

Jakob Hohlfeld
Jakob Hohlfeld

Reputation: 1574

It seems there is another/new way to do it. Recently my npm packages started to complain when I was using:

{ "license" : "LicenseRef-LICENSE" }

I'm now rather using the notation as documented in the npm docs:

If you are using a license that hasn't been assigned an SPDX identifier, or if you are using a custom license, use the following valid SPDX expression:

{ "license" : "SEE LICENSE IN <filename>" }` 

Then include a file named filename at the top level of the package.

Upvotes: 3

Arun Kumar
Arun Kumar

Reputation: 1

{
  "name": "fcc-learn-npm-package-json",
  "version": "1.0",
  "dependencies": {
    "express": "^4.14.0"
  },
  "main": "server.js",
  "scripts": {
    "start": "node server.js"
  },
  "engines": {
    "node": "8.11.2"
  },
  "repository": {
    "type": "git",
    "url": "https://idontknow/todo.git"
  },
  "author": "Ganesh",
  "description": "This is an example project",
  "keywords": [
    "freecodecamp",
    "example"
  ],
  "license": "MIT",
}

Upvotes: 0

Jonathan Bender
Jonathan Bender

Reputation: 1909

On the same page that was linked is the following:

If you are using a license that hasn't been assigned an SPDX identifier, or if you are using a custom license, use the following valid SPDX expression:

{ "license" : "LicenseRef-LICENSE" }

Then include a LICENSE file at the top level of the package.

In the same vein, you chould simply specify your URL in your LICENSE and/or copy/paste your existing license to that location.

Upvotes: 1

Related Questions