craft install
Install the project's dependencies; with package names, add them like craft add.
text
craft install [OPTIONS] [PACKAGES]...Alias: craft i. craft with no command does the same.
Options
| Option | Does |
|---|---|
--frozen-lockfile | Install exactly what craft.lock records; fail if it is missing or out of date. On by default when the CI environment variable is set. |
--production, --prod | Leave devDependencies out |
--ignore-scripts | Run no lifecycle scripts |
-D, --dev | With package names: save to devDependencies |
-E, --exact | With package names: save the exact resolved version instead of a caret range |
-O, --save-optional | With package names: save to optionalDependencies |
-P, --save-peer | With package names: save to peerDependencies, and to devDependencies so it is installed for development |
Plus the global options.
What it does
- Reads
package.jsonandcraft.lock. If they match what's already installed, printsAlready up to dateand stops. - Resolves the dependency graph, preferring the versions in
craft.lock. Dependencies whose specifier changed inpackage.jsonresolve afresh. See Lockfile. - Downloads what the global store doesn't have yet, checking each tarball's integrity.
- Lays out
node_modulesfrom the store and removes what's no longer used. See How it works. - Runs install scripts of trusted dependencies, then the project's own
preinstall,install,postinstallandprepare. - Writes
craft.lockif it changed, and prints what changed.
Examples
sh
craft install # everything in package.json
craft install --frozen-lockfile # exactly what craft.lock says
craft install --production # without devDependencies
craft i react react-dom # same as craft add react react-dom
craft i -D vitest # same as craft add -D vitestA production install leaves craft.lock unchanged, and a later craft install adds the development dependencies back.
