mirror of
https://github.com/pnpm/pnpm.git
synced 2026-02-03 03:33:21 -05:00
2.7 KiB
2.7 KiB
API
pnpm.install(pkgsToInstall, [options])
Install packages.
Arguments:
pkgsToInstall- Object | String[] - either an object that maps package names to version ranges or inputs usually passed tonpm install(e.g.,foo@1.0.0,foo).options.save- Boolean - package will appear independencies.options.saveDev- Boolean - package will appear indevDependencies.options.saveOptional- Boolean - package will appear inoptionalDependencies.options.saveExact- Boolean - saved dependencies will be configured with an exact version rather than using npm's default semver range operator.options.global- Boolean - the packages will be installed globally rather than locally.options.cwd- String - the directory in which the installation will be performed. By default theprocess.cwd()value is used.options.quiet- Boolean -falseby default. No output to the console.
Returns: a Promise
Example:
const pnpm = require('pnpm')
pnpm.install({
'is-positive': '1.0.0',
'hello-world': '^2.3.1'
}, { save: true, quiet: true })
pnpm.installPkgDeps([options])
Install all modules listed as dependencies in package.json.
Arguments: (same as in named install and additionally)
options.production- Boolean -falseby default ortruewhen theNODE_ENVenvironment variable is set toproduction. Modules listed indevDependencieswill not be installed.
pnpm.uninstall(pkgsToUninstall, [options])
Uninstalls a package, completely removing everything pnpm installed on its behalf.
Arguments:
pkgsToUninstall- String[] - the package names to be uninstalled.options.save- Boolean - the package will be removed fromdependencies.options.saveDev- Boolean - the package will be removed fromdevDependencies.options.saveOptional- Boolean - the package will be removed fromoptionalDependencies.options.global- Boolean - the packages will be uninstalled globally.
pnpm.linkFromRelative(lintTo, [options])
Create a symbolic link from the linked package to the current working directory's node_modules (and to the node_modules/.bin).
Arguments:
options.cwd- String - by defaultprocess.cwd().
pnpm.linkToGlobal([options])
Create a symbolic link from the package in the current working directory to the global node_modules.
Arguments:
options.cwd- String - by defaultprocess.cwd().
pnpm.linkFromGlobal(pkgName, [options])
Create a symbolic link to the specified package from the global node_modules to the current working directory's node_modules.
options.cwd- String - by defaultprocess.cwd().