How can I install React and Python packages on a single DigitalOcean App?
I have a Django project with a ReactJS application (index.html) directly integrated into the Django template system. This is an alternative way of integrating Django and React where you can have shared authentication and have your React app seamlessly display within the template (look and feel) of the Django website.
One issue you must overcome is getting your DigitalOcean environment built so that it includes all the packages and dependencies for Python, Django, and NodeJS/React. The DigitalOcean platform does not include any specific instructions on accomplishing this complete setup. I've struggled to find answers here too.
If you are not using Docker, DigitalOcean will have access to your code and thus it can determine what languages your site uses. If it determines you are using Python, it will load buildpacks specifically for reading your requirements.txt or Pipfile and installing all the packages listed within them.
If you add ReactJS as mentioned above, your project will now have dependencies that are managed and installed outside of the requirements.txt or Pipfile. Thus, DigitalOcean will not know of those dependencies and they will not load into your environment.
You cannot simply add the dependencies into your requirements.txt or Pipfile, since they are not intended for Python. You must instead, leave them in the package.json file, which is built out in your local environment when you use NPM to install those packages required for NodeJS and React.
DigitalOcean now only requires that you include the packages.json file when publishing to DigitalOcean. if you are deploying from a Github repo, you can simply add the packages.json file and commit it. When your repo is pushed to DigitalOcean with the packages.json file, DigitalOcean will detect the additional packages for NodeJS and React. When it detects them it associates it with a buildpack specific for NodeJS and it will install those packages.