Go to main content

man pages section 1: User Commands

Exit Print View

Updated: Thursday, June 13, 2019
 
 

npm-init (1)

Name

npm-init - create a package.json file

Synopsis

npm init [--force|-f|--yes|-y|--scope]
npm init <@scope> (same as `npx <@scope>/create`)
npm init [<@scope>/]<name> (same as `npx [<@scope>/]create-<name>`)

Description

NPM-INIT(1)                                                        NPM-INIT(1)



NAME
       npm-init - create a package.json file

SYNOPSIS
         npm init [--force|-f|--yes|-y|--scope]
         npm init <@scope> (same as `npx <@scope>/create`)
         npm init [<@scope>/]<name> (same as `npx [<@scope>/]create-<name>`)

EXAMPLES
       Create    a    new    React-based    project   using   create-react-app
       https://npm.im/create-react-app:

         $ npm init react-app ./my-react-app

       Create    a    new    esm-compatible    package    using     create-esm
       https://npm.im/create-esm:

         $ mkdir my-esm-lib && cd my-esm-lib
         $ npm init esm --yes

       Generate a plain old package.json using legacy init:

         $ mkdir my-npm-pkg && cd my-npm-pkg
         $ git init
         $ npm init

       Generate it without having it ask any questions:

         $ npm init -y

DESCRIPTION
       npm  init  <initializer>  can  be  used to set up a new or existing npm
       package.

       initializer in this case is an npm package named  create-<initializer>,
       which  will  be  installed by npm help npx https://npm.im/npx, and then
       have its main bin executed -- presumably  creating  or  updating  pack-
       age.json and running any other initialization-related operations.

       The  init  command  is  transformed to a corresponding npx operation as
       follows:

       o npm init foo -> npx create-foo

       o npm init @usr/foo -> npx @usr/create-foo

       o npm init @usr -> npx @usr/create


       Any additional options will be passed directly to the command,  so  npm
       init foo --hello will map to npx create-foo --hello.

       If  the  initializer  is  omitted (by just calling npm init), init will
       fall back to legacy init behavior. It will ask you  a  bunch  of  ques-
       tions,  and  then write a package.json for you. It will attempt to make
       reasonable guesses based on existing fields, dependencies, and  options
       selected.  It is strictly additive, so it will keep any fields and val-
       ues that were already set. You can also use -y/--yes to skip the  ques-
       tionnaire  altogether.  If  you  pass  --scope, it will create a scoped
       package.


ATTRIBUTES
       See attributes(7) for descriptions of the following attributes:


       +---------------+-------------------------+
       |ATTRIBUTE TYPE |    ATTRIBUTE VALUE      |
       +---------------+-------------------------+
       |Availability   | runtime/nodejs/nodejs-8 |
       +---------------+-------------------------+
       |Stability      | Pass-thru volatile      |
       +---------------+-------------------------+
SEE ALSO
       o https://github.com/isaacs/init-package-json

       o npm help 5 package.json

       o npm help version

       o npm help 7 scope





NOTES
       This    software    was    built    from    source     available     at
       https://github.com/oracle/solaris-userland.    The  original  community
       source   was   downloaded   from     https://github.com/nodejs/node/ar-
       chive/v8.15.1.zip

       Further information about this software can be found on the open source
       community website at https://github.com/nodejs/node.



                                  August 2018                      NPM-INIT(1)