it:ad:npm:howto:create_a_package.json_file

IT:AD:NPM:HowTo:Create a package.json File

Summary

NPM manages the packages needed in your project using a package.json file.

After using a IT:AD:CLI to navigate to your project's directory, you can create one by hand:

{
  "name": "Foo",
  "version": "0.0.1",
  "devDependencies": {
    "grunt": "~0.4.1"
  }
}

Basic concepts: * name and version are required, and form the identity of the package. * name: an url safe string. Should not include '.js' (js is implied as you are using npm). * version: a string. Should be updated for each package release. * description: a string description * keywords: an array of string keywords of your choosing * homepage: an string url the project homepage * license: a string of the license spdx (“MIT”, etc.) * author:

  • An object: {"name":"foo", "email":"foo@foo.com", "url":"//foo.com"}

* contributors: an array of objects. [{"name":"foo", "email":"foo@foo.com", "url":"//foo.com"}...] * files: name of file, or folder containing files. * main: the primary file. * bin: files to register in the PATH. * dependencies: https://www.npmjs.org/doc/files/package.json.html#dependencies

Or you can use grunt init to create the file – but it's more verbose:

{
  "name": "Foo",
  "version": "0.0.1",
  "description": "A footuristic solution",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Sky",
  "license": "ISC"
}

The specs for a package.json file can be found at the NPM site: * https://www.npmjs.org/doc/files/package.json.html

  • /home/skysigal/public_html/data/pages/it/ad/npm/howto/create_a_package.json_file.txt
  • Last modified: 2023/11/04 01:51
  • by 127.0.0.1