Heroku: run npm install and build gulp for a Django application

I have a Django application that I was able to deploy with Heroku. My Procfile contains only:

 web: gunicorn omegapp3.wsgi --log-file - 

So when I run heroku local , it works.

But when I deploy using heroku push master , the console detects the Node application because the application has package.json , and then the build fails.

I would like to do the following:

  • run npm install to install gulp etc.
  • run gulp build.

Do you know how I can do this?

+5
source share
2 answers

According to the official documentation, you should add several buildpacks to your installation, and not one multi-line package.

For example, if you want to deploy an application that uses the Nodejs package (i.e. grunt, gulp, etc.) to perform some configuration in your application, you should run this from the command line:

 heroku buildpacks:add --index 1 heroku/nodejs 

The add command adds the Nodejs collector as an optional buildpack, and does not replace your current buildpack. Pay attention to --index 1 . This indicates that Nodejs buildpack is the first in order to build packages. This is important because the final buildpack is the one used for the actual type of process. You can call heroku buildpacks from the command line to verify the installation of buildpack. I am running a Python application, so my heroku buildpacks looks like this:

 === your_app_name_here Buildpack URLs 1. heroku/nodejs 2. https://github.com/heroku/heroku-buildpack-python 

Then, as indicated in the rocket, you can put it in your package.json file, which will be launched during deployment:

 "scripts": { "postinstall": "./node_modules/.bin/gulp build" } 
+6
source

Solved using $ heroku buildpacks:set https://github.com/heroku/heroku-buildpack-multi.git .
It allows you to use node and python (you must specify in the .buildpacks file). In ordre, to run gulp build I added the following to package.json :

 "scripts": { "postinstall": "./node_modules/.bin/gulp build" } 
+1
source

Source: https://habr.com/ru/post/1237515/


All Articles