Thursday, 11 May 2017

How to npm install on Heroku

I would like to to deploy my app on Heroku through bitbucket-pipeline. Flow is as follows.

  1. composer install
  2. npm install
  3. Laravel-Mix(gulp task and brouserify and so on...)

These will be needed because "vendor" and "node_modules" are written in gitignore. Now 2 and 3 are failed to build. I guess it caused package.json or bitbucket-pipelines.yml, but I do not know how to code. Please give me solutions?

※nodejs buildpack is already installed ※I can npm install in Heroku app when I tried "heroku run bash", then "npm install"

Here is my "package.json" and "bitbucket-pipelines.yml" (Laravel5.4)

package.json

{
  "private": true,
  "scripts": {
    "dev": "npm run development",
    "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch-poll": "npm run watch -- --watch-poll",
    "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
    "prod": "npm run production",
    "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
  },
  "devDependencies": {
    "axios": "^0.15.3",
    "bootstrap-sass": "^3.3.7",
    "cross-env": "^3.2.3",
    "jquery": "^3.1.1",
    "laravel-mix": "0.*",
    "lodash": "^4.17.4",
    "vue": "^2.1.10"
  }
}

bitbucket-pipelines.yml

// bitbucket-pipelines.yml

image: phpunit/phpunit:5.0.3
clone:
  depth: full
pipelines:
  default:
    - step:
        script: # Modify the commands below to build your repository.
          - composer install
          - npm install
          - npm run production
          - git push https://heroku: test-stg.git HEAD



via Kazuki

No comments:

Post a Comment