Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to have package.json not at top level of heroku app

I have this app that deploys to heroku:

https://github.com/justin808/react-webpack-rails-tutorial

http://react-webpack-rails-tutorial.herokuapp.com/

The technique is described here: http://www.railsonmaui.com/blog/2014/10/02/integrating-webpack-and-the-es6-transpiler-into-an-existing-rails-project/

Currently, package.json is at the root level of the project.

How do move the /package.json and /node_modules to be inside of the /webpack directory?

I.e., how do I tell the node buildpack where to look for package.json?

like image 428
justingordon Avatar asked Dec 17 '14 06:12

justingordon


People also ask

Does Heroku need package lock json?

Heroku uses the lockfiles, either the package-lock. json or yarn. lock , to install the expected dependency tree, so be sure to check those files into git to ensure the same dependency versions across environments. If you are using npm, Heroku will use npm ci to set up the build environment.

Why does my app fail to detect a Buildpack?

This error message means that Heroku was unable to automatically detect the type of app you're trying to deploy: Ruby, Node, Python, PHP, Java, etc. We look for signatures for each language we support (like a pom. xml file or package. json file).

Does Heroku run npm start?

By default, Heroku runs npm start while starting deployed Node. js applications, but if you would like to run some other script from your package. json instead you just need to follow one simple step. And that's it!


1 Answers

The fix is to use this in package.json:

  "scripts": {
    "postinstall": "cd client && npm install",

You can see the full details here: https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/package.json#L10

like image 141
justingordon Avatar answered Oct 07 '22 01:10

justingordon