Skip to main content

Managing Dependencies

Dependencies are external libraries or modules that your project relies on. Proper management of these dependencies ensures your project runs consistently across different environments.

We recommend to pin your dependencies to avoid unexpected issues when newer versions introduce breaking changes that disrupt your workflow during deployments. It ensures that your project uses specific versions that have been tested and proven to work.

Create a package.json file in the root of your project by running docker compose run --rm web npm init to install all your dependencies with their versions. For example:

{
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
}

Then generate a package-lock.json file by running:

docker compose run --rm web npm install

Continue installing dependencies through:

docker compose run --rm web npm install react@18.2.0 react-dom@18.2.0 --save

To avoid issues between your local environment and Divio Cloud, use docker compose to manage/install your dependencies and not your local setup.

Developing locally

We recommend using docker compose to manage your dependencies locally and ensure consistency between your local environment and Divio Cloud. Otherwise you may run into issues where your local environment works but the deployment fails. For this, prepend all commands with: docker compose run --rm web

Checking for CDN/Package Manager Errors

Before assuming a dependency issue is on our end, always check if the problem is with the package manager or CDN itself. Sometimes, connectivity or service outages can cause errors that aren't related to our setup. Here's a list of common package managers and their status pages:

Always verify that these services are operational before diving deep into troubleshooting on your side.

Why Pinning Dependencies is Important

Pinning dependencies is essential for maintaining consistency across development and production environments over time, but running your applications directly on your local machine still exposes you to the classic "works on my machine" syndrome.

Instead, consider using Docker and Docker Compose for your development and CI/CD pipelines. This approach ensures that the exact environment, including OS, dependencies, and configurations, is mirrored across all stages of development and deployment.

Divio containerizes your applications to reduce the risk of deployment issues and make it easier to reproduce any bugs or discrepancies between local development and cloud environments. Docker also provides isolation, which helps avoid conflicts between different projects on the same machine.

The Wheels Proxy

Used in legacy templates

The wheels proxy continues to be supported by Divio, but we do not recommend using it for new applications. Use our quickstart templates instead.

Divio Cloud provides a wheels proxy to cache and serve Python packages. This proxy ensures that your Python dependencies are available even if the PyPI service is down. The proxy also speeds up the installation process by caching packages locally.

Read more about Divio's wheels proxy.