Dev Dependencies
Keep test and build tools out of production with --saveDev and --production.
Some packages are only needed while you build and test your app. In this lesson you will save a package as a dev dependency and then install your project without it.
Save a dev dependency
Add the --saveDev flag when you install. CommandBox records the package under devDependencies instead of dependencies in your box.json.
box install testbox --saveDev
{
"dependencies": {
"cbvalidation": "^4.0.0"
},
"devDependencies": {
"testbox": "^6.0.0"
}
}
Versions above are examples. Yours will match what was just installed.
Install everything, or just production
Run install with no package name and CommandBox installs everything listed in your box.json. By default that includes dev dependencies.
box install
On a production server or in a deploy pipeline, skip the dev tools with --production.
box install --production
Use plain box install on your own machine and in CI where you run tests. Use box install --production when you build the artifact you ship.
Where packages land
Each installed package is tracked in installPaths in box.json, mapping its slug to the folder it was installed into. CommandBox manages this for you.
{
"installPaths": {
"testbox": "testbox/"
}
}
You can set a path before installing to control the destination, using package set.
box package set installPaths.testbox=lib/testbox/
box package show installPaths
Recap
box install <package> --saveDevrecords the package underdevDependencies.box installinstalls everything,box install --productionskips dev dependencies.installPathsinbox.jsonmaps each package slug to its install folder.