Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. # IT:AD:NPM:HowTo:Create a package.json File # * [[./|(UP)]] * See also: * [[IT:AD:npm:HowTo:Define Needed Global Packages In Package.json File]] <callout type="Navigation" class="small"> * [[IT/AD/Grunt/HowTo/Setup]] </callout> <panel title="Summary"> NPM manages the packages needed in your project using a `package.json` file. </panel> ## Process ## After using a [[IT/AD/CLI/]] to navigate to your project's directory, you can create one by hand: <sxh json> { "name": "Foo", "version": "0.0.1", "devDependencies": { "grunt": "~0.4.1" } } </sxh> 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](https://spdx.org/licenses/) ("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 ### Using Grunt Init Or you can use `grunt init` to create the file -- but it's more verbose: <sxh json> { "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" } </sxh> ### Going Further The specs for a package.json file can be found at the NPM site: * https://www.npmjs.org/doc/files/package.json.html ## Resources ## * 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:51by 127.0.0.1