npm-install | npm Docs

Synopsis

 

npm

install

[

<

@scope

>

/

]

<

pkg

>

npm

install

[

<

@scope

>

/

]

<

pkg

>

@

<

tag

>

npm

install

[

<

@scope

>

/

]

<

pkg

>

@

<

version

>

npm

install

[

<

@scope

>

/

]

<

pkg

>

@

<

version range

>

npm

install

<

alias

>

@npm:

<

name

>

npm

install

<

folder

>

npm

install

<

tarball file

>

npm

install

<

tarball url

>

npm

install

<

git:// url

>

npm

install

<

github username

>

/

<

github project

>

aliases: i, in, ins, inst, insta, instal, isnt, isnta, isntal, isntall,

add

Description

This command installs a box and any packages that it depends on. If the package has a package-lock, or an npm shrinkwrap charge, or a yarn lock file, the facility of dependencies will be driven by that, respecting the following order of priority :

  • npm-shrinkwrap.json
  • package-lock.json
  • yarn.lock

See package-lock.json and npm shrinkwrap. A package is :

  • a) a folder containing a program described by a
    package.json file
  • b) a gzipped tarball containing (a)
  • c) a url that resolves to (b)
  • d) a @ that is published on the registry (see
    registry) with (c)
  • e) a @ (see npm dist-tag) that
    points to (d)
  • f) a that has a “latest” tag satisfying (e)
  • g) a that resolves to (a)

flush if you never publish your package, you can still get a set of benefits of using npm if you precisely want to write a lymph node program ( a ), and possibly if you besides want to be able to easily install it elsewhere after packing it up into a tarball ( boron ) .

  • npm install ( in a software directory, no arguments ) : Install the dependencies to the local node_modules folder. In ball-shaped mode ( i, with -g or --global appended to the command ), it installs the current software context ( internet explorer, the current work directory ) as a ball-shaped package. By default, npm install will install all modules listed as dependencies in package.json. With the --production pin ( or when the NODE_ENV environment variable is set to production ), npm will not install modules listed in devDependencies. To install all modules listed in both dependencies and devDependencies when NODE_ENV environment variable is set to production, you can use --production=false .

    bill : The --production flag has no particular meaning when adding a colony to a project .

  • npm install : If sits inside the beginning of your plan, its dependencies will be installed and may be hoisted to the top-level node_modules as they would for other types of dependencies. If sits outside the root of your undertaking, npm will not install the software dependencies in the directory , but it will create a symlink to .

    note : If you want to install the content of a directory like a package from the register alternatively of creating a link, you would need to use npm pack while in the directory, and then install the resulting tarball rather of the using npm install

    Example :

     

    npm

    install

    ..

    /

    ..

    /other-package

    npm

    install

    ./sub-package

  • npm install : Install a box that is sitting on the filesystem. note : if you barely want to link a dev directory into your npm beginning, you can do this more well by using npm link. Tarball requirements :
    • The filename must use .tar, .tar.gz, or .tgz as the extension .
    • The software contents should reside in a subfolder inside the tarball ( normally it is called package/ ). npm strips one directory layer when installing the package ( an equivalent of tar x
      --strip-components=1
      is run ) .
    • The box must contain a package.json file with name and version properties. Example :
       

      npm

      install

      ./package.tgz

  • npm install : Fetch the tarball url, and then install it. In order to distinguish between this and early options, the argument must start with “ hypertext transfer protocol : // ” or “ hypertext transfer protocol : // ” Example :
     

    npm

    install

    https://github.com/indexzero/forever/tarball/v0.5.6

  • npm install [<@scope>/] : Do a @ install, where is the “ tag ” config. ( See config. The config ‘s default value is latest. ) In most cases, this will install the translation of the modules tagged as latest on the npm register. Example :
     

    npm

    install

    sax

    npm install saves any assign packages into dependencies by nonpayment. additionally, you can control where and how they get saved with some extra flags :

    • -P, --save-prod : package will appear in your dependencies. This is the default unless -D or -O are confront .
    • -D, --save-dev : software will appear in your devDependencies .
    • -O, --save-optional : package will appear in your optionalDependencies .
    • --no-save : Prevents saving to dependencies. When using any of the above options to save dependencies to your package.json, there are two extra, optional flags :
    • -E, --save-exact : Saved dependencies will be configured with an claim version rather than using npm ‘s default semver rate operator .
    • -B, --save-bundle : Saved dependencies will besides be added to your bundleDependencies tilt. far, if you have an npm-shrinkwrap.json or package-lock.json then it will be updated ampere good. is optional. The box will be downloaded from the register associated with the specified setting. If no register is associated with the given scope the nonpayment register is assumed. See scope. note : if you do not include the @ -symbol on your scope mention, npm will interpret this as a GitHub repository alternatively, see below. Scopes names must besides be followed by a convulse. Examples :
       

      npm

      install

      sax

      npm

      install

      githubname/reponame

      npm

      install

      @myorg/privatepackage

      npm

      install

      node-tap --save-dev

      npm

      install

      dtrace-provider --save-optional

      npm

      install

      readable-stream --save-exact

      npm

      install

      ansi-regex --save-bundle

      Note : If there is a file or booklet named in the current bring directory, then it will try to install that, and only try to fetch the package by name if it is not valid .

  • npm install @npm: : Install a package under a custom alias. Allows multiple versions of a same-name package side-by-side, more convenient import names for packages with otherwise long ones, and using rotter forks replacements or forked npm packages as replacements. Aliasing works alone on your project and does not rename packages in transitive verb dependencies. Aliases should follow the mention conventions stated in validate-npm-package-name. Examples :
     

    npm

    install

    my-react@npm:react

    npm

    install

    jquery2@npm:jquery@2

    npm

    install

    jquery3@npm:jquery@3

    npm

    install

    npa@npm:npm-package-arg

  • npm install [<@scope>/]@ : Install the translation of the software that is referenced by the pin down tag. If the tag does not exist in the register data for that software, then this will fail. Example :
     

    npm

    install

    sax@latest

    npm

    install

    @myorg/mypackage@latest

  • npm install [<@scope>/]@ : Install the assign adaptation of the package. This will fail if the interpretation has not been published to the register. Example :
     

    npm

    install

    sax@0.1.1

    npm

    install

    @myorg/privatepackage@1.5.0

  • npm install [<@scope>/]@ : Install a version of the software matching the specified translation range. This will follow the same rules for resolving dependencies described in package.json. eminence that most version ranges must be put in quotes so that your husk will treat it as a one argument. Example :
     

    npm

    install

    sax@

    ">=0.1.0 <0.2.0"

    npm

    install

    @myorg/privatepackage@

    "16 - 17"

  • npm install : Installs the package from the hosted rotter supplier, cloning it with git. For a wax rotter distant url, only that URL will be attempted .
     

    <

    protocol

    >

    ://

    [

    <

    user

    >

    [

    :

    <

    password

    >

    ]

    @

    ]

    <

    hostname

    >

    [

    :

    <

    port

    >

    ]

    [

    :

    ]

    [

    /

    ]

    <

    path

    >

    [

    is one of git, git+ssh, git+http, git+https, or git+file. If # is provided, it will be used to clone precisely that commit. If the commit-ish has the format #semver:, can be any valid semver range or demand version, and npm will look for any tags or refs matching that range in the distant repository, much as it would for a register dependence. If neither # or #semver: is specified, then the default option branch of the depository is used. If the repository makes use of submodules, those submodules will be cloned equally well. If the box being installed contains a prepare handwriting, its dependencies and devDependencies will be installed, and the cook handwriting will be run, before the box is packaged and installed. The be rotter environment variables are recognized by npm and will be added to the environment when running rotter :

    • GIT_ASKPASS
    • GIT_EXEC_PATH
    • GIT_PROXY_COMMAND
    • GIT_SSH
    • GIT_SSH_COMMAND
    • GIT_SSL_CAINFO
    • GIT_SSL_NO_VERIFY See the rotter man foliate for details. Examples :
       

      npm

      install

      git+ssh://git@github.com:npm/cli.git

      npm

      install

      git+ssh://git@github.com:npm/cli

      npm

      install

      git+ssh://git@github.com:npm/cli

      npm

      install

      git+https://isaacs@github.com/npm/cli.git

      npm

      install

      git://github.com/npm/cli.git

      GIT_SSH_COMMAND

      =

      'ssh -i ~/.ssh/custom_ident'

      npm

      install

      git+ssh://git@github.com:npm/cli.git

  • npm install /[#] :
  • npm install github:/[#] : Install the package at https://github.com/githubname/githubrepo by attempting to clone it using git. If # is provided, it will be used to clone precisely that commit. If the commit-ish has the format #semver:, can be any valid semver roll or claim adaptation, and npm will look for any tags or refs matching that range in the outside repository, much as it would for a register addiction. If neither # or #semver: is specified, then master is used. As with regular rotter dependencies, dependencies and devDependencies will be installed if the package has a prepare script before the software is done install. Examples :
     

    npm

    install

    mygithubuser/myproject

    npm

    install

    github:mygithubuser/myproject

  • npm install gist:[/][#|#semver:] : Install the package at https://gist.github.com/gistID by attempting to clone it using git. The GitHub username associated with the effect is optional and will not be saved in package.json. As with regular rotter dependencies, dependencies and devDependencies will be installed if the box has a prepare script before the box is done installation. Example :
     

    npm

    install

    gist:101a11beef

  • npm install bitbucket:/[#] : Install the box at https://bitbucket.org/bitbucketname/bitbucketrepo by attempting to clone it using git. If # is provided, it will be used to clone precisely that give. If the commit-ish has the format #semver:, can be any valid semver stove or accurate interpretation, and npm will look for any tags or refs matching that range in the remote control depository, a lot as it would for a register addiction. If neither # or #semver: is specified, then master is used. As with regular rotter dependencies, dependencies and devDependencies will be installed if the package has a prepare script before the package is done install. Example :
     

    npm

    install

    bitbucket:mybitbucketuser/myproject

  • npm install gitlab:/[#] : Install the software at https://gitlab.com/gitlabname/gitlabrepo by attempting to clone it using git. If # is provided, it will be used to clone precisely that perpetrate. If the commit-ish has the format #semver:, can be any valid semver scope or demand adaptation, and npm will look for any tags or refs matching that compass in the outside repository, a lot as it would for a register colony. If neither # or #semver: is specified, then master is used. As with even rotter dependencies, dependencies and devDependencies will be installed if the package has a prepare script before the software is done install. Example :
     

    npm

    install

    gitlab:mygitlabuser/myproject

    npm

    install

    gitlab:myusr/myproj

You may combine multiple arguments and even multiple types of arguments. For exemplar :

 

npm

install

sax@

">=0.1.0 <0.2.0"

bench supervisor

The --tag argument will apply to all of the specified install targets. If a tag with the given name exists, the tag translation is preferred over newer versions. The --dry-run argument will report in the usual way what the install would have done without actually installing anything. The --package-lock-only argumentation will only update the package-lock.json, rather of checking node_modules and downloading dependencies. The -f or --force argument will force npm to fetch outside resources tied if a local copy exists on disk .

 

npm

install

sax --force

Configuration

See the config avail doctor. Many of the configuration params have some effect on installation, since that ‘s most of what npm does. These are some of the most common options related to installation .

save

  • Default: true unless when using npm update or npm dedupe where it
    defaults to false
  • Type: Boolean

Save installed packages to a package.json file as dependencies. When used with the npm rm command, removes the dependence from package.json. Will besides prevent writing to package-lock.json if set to false .

  • Default: false
  • Type: Boolean

Dependencies saved to package.json will be configured with an exact interpretation preferably than using npm ‘s default semver range operator .

global

  • Default: false
  • Type: Boolean

Operates in “ ball-shaped ” mood, so that packages are installed into the prefix folder rather of the current work directory. See folders for more on the differences in demeanor .

  • packages are installed into the {prefix}/lib/node_modules folder, instead
    of the current working directory.
  • bin files are linked to {prefix}/bin
  • man pages are linked to {prefix}/share/man
  • Default: false
  • Type: Boolean

Causes npm to install the package into your local node_modules booklet with the lapp layout it uses with the ball-shaped node_modules folder. merely your conduct dependencies will show in node_modules and everything they depend on will be flattened in their node_modules folders. This obviously will eliminate some deduping. If used with legacy-bundling, legacy-bundling will be preferred .

  • Default: false
  • Type: Boolean

Causes npm to install the package such that versions of npm prior to 1.4, such as the one included with lymph node 0.8, can install the box. This eliminates all automatic deduping. If used with global-style this choice will be preferred .

omit

  • Default: ‘dev’ if the NODE_ENV environment variable is set to
    ‘production’, otherwise empty.
  • Type: “dev”, “optional”, or “peer” (can be set multiple times)

Dependency types to omit from the facility tree on magnetic disk. notice that these dependencies are still resolved and added to the package-lock.json or npm-shrinkwrap.json file. They are just not physically installed on disk. If a package type appears in both the --include and --omit lists, then it will be included. If the resulting exclude list includes 'dev', then the NODE_ENV environment variable will be set to 'production' for all lifecycle scripts .

  • Default: false
  • Type: Boolean

If set to true, and --legacy-peer-deps is not set, then any conflicting peerDependencies will be treated as an install failure, even if npm could reasonably guess the appropriate resolution based on non-peer addiction relationships. By nonpayment, conflicting peerDependencies deep in the addiction graph will be resolved using the nearest non-peer dependence stipulation, even if doing sol will result in some packages receiving a peer colony outside the scope set in their package ‘s peerDependencies object. When such and nullification is performed, a warn is printed, explaining the conflict and the packages involved. If --strict-peer-deps is set, then this warn is treated as a failure .

  • Default: true
  • Type: Boolean

If set to false, then ignore package-lock.json files when installing. This will besides prevent writing package-lock.json if save is true. When software package-locks are disable, automatic rifle pruning of extraneous modules will besides be disabled. To remove external modules with package-locks disable use npm prune. This shape does not affect npm ci .

  • Default: false
  • Type: Boolean

Run all build scripts ( i, preinstall, install, and postinstall ) scripts for install packages in the foreground process, sharing standard input, output signal, and error with the main npm process. notice that this will by and large make installs run slower, and be much noisier, but can be utilitarian for debugging .

  • Default: false
  • Type: Boolean

If genuine, npm does not run scripts specified in package.json files. note that commands explicitly intended to run a particular script, such as npm start, npm stop, npm restart, npm test, and npm run-script will placid run their intended script if ignore-scripts is set, but they will not run any pre- or post-scripts .

audit

  • Default: true
  • Type: Boolean

When “ true ” resign audit reports alongside the current npm command to the nonpayment register and all registries configured for scopes. See the documentation for npm audit for details on what is submitted .

  • Default: true
  • Type: Boolean

Tells npm to create symlinks ( or .cmd shims on Windows ) for package executables. fix to false to have it not do this. This can be used to work around the fact that some file systems do n’t support symlinks, even on apparently Unix systems .

fund

  • Default: true
  • Type: Boolean

When “ on-key ” displays the message at the end of each npm install acknowledging the number of dependencies looking for fund. See npm
fund
for details .

  • Default: false
  • Type: Boolean

Indicates that you do n’t want npm to make any changes and that it should lone report what it would have done. This can be passed into any of the commands that modify your local installation, eg, install, update, dedupe, uninstall, deoxyadenosine monophosphate well as pack and publish. note : This is NOT honored by other network related commands, eg dist-tags, owner, etc .

workspace

  • Default:
  • Type: String (can be set multiple times)

enable running a command in the context of the configure workspaces of the current project while filtering by running merely the workspaces defined by this configuration option. valid values for the workspace config are either :

  • Workspace names
  • Path to a workspace directory
  • Path to a parent workspace directory (will result in selecting all
    workspaces within that folder)

When set for the npm init command, this may be set to the booklet of a workspace which does not however exist, to create the folder and set it up as a brand newfangled workspace within the project. This respect is not exported to the environment for child processes .

workspaces

  • Default: null
  • Type: null or Boolean

Set to genuine to run the command in the context of all configured workspaces. explicitly setting this to false will cause commands like install to ignore workspaces wholly. When not set explicitly :

  • Commands that operate on the node_modules tree (install, update, etc.)
    will link workspaces into the node_modules folder. – Commands that do
    other things (test, exec, publish, etc.) will operate on the root project,
    unless one or more workspaces are specified in the workspace config.

This value is not exported to the environment for child processes .

  • Default: false
  • Type: Boolean

Include the workspace beginning when workspaces are enabled for a dominate. When fake, specifying individual workspaces via the workspace config, or all workspaces via the workspaces masthead, will cause npm to operate only on the intend workspaces, and not on the solution project .

Algorithm

Given a package{dep} structure : A{B,C}, B{C}, C{D}, the npm install algorithm produces :

 

A

+-- B

+-- C

+-- D

That is, the addiction from B to C is satisfied by the fact that A already caused C to be installed at a higher level. D is still installed at the top tied because nothing conflicts with it. For A{B,C}, B{C,D@1}, C{D@2}, this algorithm produces :

 

A

+-- B

+-- C

`-- D@2

+-- D@1

Because B ‘s D @ 1 will be installed in the top-level, C immediately has to install D @ 2 privately for itself. This algorithm is deterministic, but different trees may be produced if two dependencies are requested for installation in a different order. See folders for a more detail description of the specific folder structures that npm creates .

See Also

source : https://thefartiste.com
Category : Tech

About admin

I am the owner of the website thefartiste.com, my purpose is to bring all the most useful information to users.

Check Also

articlewriting1

Manage participants in a zoom meeting webinar

Call the people who attend the meet as follows Alternate host host Who scheduled the …

Leave a Reply

Your email address will not be published.