Header Ads

Sunday, March 22, 2020

0 comments


NPM Install


This command installs a package, and any packages that it depends on. If the package has a package-lock or shrinkwrap file, the installation of dependencies will be driven by that, with an npm-shrinkwrap.json taking precedence if both files exist. See package-lock.json and npm-shrinkwrap.






  • npm install (in package directory, no arguments):
    Install the dependencies in the local node_modules folder.
    In global mode (ie, with -g or --global appended to the command), it installs the current package context (ie, the current working directory) as a global package.
    By default, npm install will install all modules listed as dependencies in package.json.
    With the --production flag (or when the NODE_ENV environment variable is set to production), npm will not install modules listed in devDependencies.
    NOTE: The --production flag has no particular meaning when adding a dependency to a project.
  • npm install <folder>:
    Install the package in the directory as a symlink in the current project. Its dependencies will be installed before it’s linked. If <folder> sits inside the root of your project, its dependencies may be hoisted to the toplevel node_modules as they would for other types of dependencies.
  • npm install <tarball file>:
    Install a package that is sitting on the filesystem. Note: if you just want to link a dev directory into your npm root, you can do this more easily by using npm link.
    Tarball requirements:
    • The filename must use .tar.tar.gz, or .tgz as the extension.
    • The package contents should reside in a subfolder inside the tarball (usually it is called package/). npm strips one directory layer when installing the package (an equivalent of tar x --strip-components=1 is run).
    • The package must contain a package.json file with name and version properties.
    Example:
        npm install ./package.tgz
    


No comments:

Post a Comment