Missing dependencies
If your application works locally but doesn’t work when deployed this may be due to dependencies which are installed globally rather than being enumerated in the package.json file. In order to deploy an application, it needs to be self-contained. You can resolve this by adding the dependency to yourpackage.json, typically by
using a command such as yarn add or npm install.
Mis-categorized dependencies
Manypackage.json files have two lists of dependencies: dependencies and devDependencies.
devDependencies are intended to list dependencies which are only needed at build time and
not when deployed. Sometimes dependencies are miscategorized, for example a database tool
needed to perform migration may be listed as a devDependency despite the fact that such a
tool is needed to deploy.
It is generally best to correct these errors by moving the dependency to the right place in
the package.json. An alternative when this isn’t feasible or desired is to regenerate the
dockerfile to include all dependencies at deployment:
Legacy peer dependencies
Somepackage.json files have a third set of dependencies peerDependencies. As tooling
support for this varies, this information can become stale and out of sync, causing builds
to fail. While correcting these dependencies may work for a while, often times it becomes
necessary to indicate that these dependencies are legacy. The way to do this varies
based on the package manager, and dockerfile-node can take care of this for you: