gjaldon / heroku-buildpack-phoenix-static

A Heroku buildpack for building Phoenix's static assets
MIT License
230 stars 224 forks source link

Error during npm package install, node_modules directory not found #47

Closed ntilwalli closed 7 years ago

ntilwalli commented 7 years ago

I'm using an npm script... to generate my production assets (not brunch) and I was consistently getting a stat indicating the node_modules directory did not exist. The error is happening on this line: https://github.com/gjaldon/heroku-buildpack-phoenix-static/blob/master/lib/build.sh#L91

I fixed the error by prepending the $build_dir to the directory name as shown here: https://github.com/ntilwalli/heroku-buildpack-phoenix-static/blob/master/lib/build.sh#L111

I dunno if this only surfaces for people not using brunch or webpack, but since no one else has complained it seems that way. Any thoughts? Does this merit a PR?

gjaldon commented 7 years ago

https://github.com/gjaldon/heroku-buildpack-phoenix-static/blob/master/lib/build.sh#L91 expects that the node_modules are inside the phoenix directory. This is what the phoenix_dir is https://github.com/gjaldon/heroku-buildpack-phoenix-static/blob/master/lib/common.sh#L40.

$build_dir/node_modules refers to node_modules outside of the phoenix project's directory. How does your npm script look like? Maybe you could change it to ensure that node_modules dir is going to be in phoenix?

ntilwalli commented 7 years ago

Ah. That explains it. Yeah my node_modules is at the root of my umbrella app. My Phoenix app's Endpoint configuration uses a watchers keyword entry that looks like watchers: [exit_on_eof: ["npm run watch"]] which means it needs to be able to run an npm script. When I move the package.json down to the Phoenix directory and install the dependencies there, and then run mix phoenix.server from the root of the umbrella, the watchers command tries to run npm run watch and looks for the package.json at the root of the umbrella (where I started the app) and does not find it, since it's now in the Phoenix dir. Do you know how I can indicate where the package.json is?

ntilwalli commented 7 years ago

Adding a cd: keyword list argument fixed my issue like so:

watchers: [exit_on_eof: ["npm run watch", cd: Path("../", __DIR__)]]

Thanks.

gjaldon commented 7 years ago

Great to hear you were able to find a solution!

On Thu, Nov 10, 2016 at 8:44 PM, Nikhil Tilwalli notifications@github.com wrote:

Adding a cd: keyword list argument fixed my issue like so:

watchers: [exit_on_eof: ["npm run watch", cd: Path("../", DIR)]]

Thanks.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/gjaldon/heroku-buildpack-phoenix-static/issues/47#issuecomment-259680875, or mute the thread https://github.com/notifications/unsubscribe-auth/ABY-QvonUS6qZk08vsdMHXKWQ0RfPqn0ks5q8xGTgaJpZM4KuJ3n .

Gabe Jaldon