heroku / heroku-buildpack-nodejs

Heroku's buildpack for Node.js applications.
https://devcenter.heroku.com/articles/buildpacks
MIT License
3 stars 1 forks source link

problem installing package from public github repo #760

Closed hems closed 4 years ago

hems commented 4 years ago

I have been trying to have a public github repo as dependency on package.json and although it works locally as expected it fails on heroku.

examples using a branch:

"simpleddp": "https://github.com/hems/simpleddp.git#patch-2"

example using a commit:

"simpleddp": "hems/simpleddp.git#0396884068078c06fbceedc2508cf88bab967b96",

i also tried tarball and it did not work.. Eventually on my build on heroku i get the error

Module not found: Can't resolve 'simpleddp' in [...]

danielleadams commented 4 years ago

Hi @hems, I answered your support ticket, but I'll answer here for visibility too. This should work, but I would use the git protocol as suggested in the NPM docs: https://docs.npmjs.com/files/package.json#git-urls-as-dependencies

Regardless of what the issue is, if you're seeing a difference between Heroku and your local machine, my initial guess would be that it is because you have read/write access to the repository via git/GitHub on your local machine. Even though it's a public repository, Heroku will still haven't different access and would receive a 404 when trying to read (assuming that the Module not found is the error you're seeing).

I think we could use some supplemental docs regarding using git urls for dependencies, so I'm going to tag this as a documentation. Happy to keep discussing here for transparency or we can continue our discussion via the suppor ticket.

hems commented 4 years ago

Hi @hems, I answered your support ticket, but I'll answer here for visibility too. This should work, but I would use the git protocol as suggested in the NPM docs: https://docs.npmjs.com/files/package.json#git-urls-as-dependencies

I just used:

"simpleddp": "git://github.com/hems/simpleddp.git#patch-2",

as you suggested and the error I got in the end was:

remote: -----> Build failed

which is a less than ideal error message.

If i use the regular

"simpleddp": "^2.2.4",

It works as expected, so surely the problem is the git url.

Regardless of what the issue is, if you're seeing a difference between Heroku and your local machine, my initial guess would be that it is because you have read/write access to the repository via git/GitHub on your local machine. Even though it's a public repository, Heroku will still haven't different access

I don't understand how it would be possible for Heroku to not have access to a public repository on GitHub?

and would receive a 404 when trying to read (assuming that the Module not found is the error you're seeing).

The error I'm seeing is just "Build Failed".

I think we could use some supplemental docs regarding using git urls for dependencies, so I'm going to tag this as a documentation. Happy to keep discussing here for transparency or we can continue our discussion via the suppor ticket.

Definitely could do with supplemental documentation, but i think the feature still no working a expected?

Does it work for you?

hems commented 4 years ago

Turns out after a clean slate and properly debugging some of my project that

"simpleddp": "git://github.com/hems/simpleddp.git#patch-2"

on the package.json works as expected! thank you

hems commented 4 years ago

Also, there is something funny about "yarn" for me, if i use it to install locally it will generate a yarn.lock and when i deploy to heroku the deploy fails.

If i use npm to install and push a package-lock.json to Heroku then the build succeeds.

danielleadams commented 4 years ago

@hems do you have a build ID from this output? You can get it from from visiting the "Activity" tab of an app, clicking on the build, and copying this value:

build-id

I tried running a build both locally and on Heroku with your forked dependency with both https and git protocols, and everything worked, so I'm going to need more information.

From the logs you've pasted, it looks like the build is getting further than install and that this is not because of an install, but I will need the full logs to fully investigate.

danielleadams commented 4 years ago

@hems has this issue been resolved?

hems commented 4 years ago

@hems has this issue been resolved?

this was resolved, thank you!

cstayyab commented 2 years ago

Turns out after a clean slate and properly debugging some of my project that

"simpleddp": "git://github.com/hems/simpleddp.git#patch-2"

on the package.json works as expected! thank you

This isn't working for me I am still getting the same error. Should I open up a new issue? The repo I am using is a fork and here is its URL: https://github.com/cstayyab/capturl

KicksTV commented 2 years ago

I am also running into this issue.

"dat.gui": "git://github.com:KicksTV/dat.gui.git",

but gives me a very long error. Will include what I think is most relavant.

Installing node modules remote: npm ERR! code 1 remote: npm ERR! git dep preparation failed remote: npm ERR! command /tmp/build_33dd61a3/.heroku/node/bin/node /tmp/build_33dd61a3/.heroku/node/lib/node_modules/npm/bin/npm-cli.js install --force --cache=/tmp/npmcache.2vea7 --prefer-offline=false --prefer-online=false --offline=false --no-progress --no-save --no-audit --include=dev --include=peer --include=optional --no-package-lock-only --no-dry-run remote: npm ERR! npm ERR! code 1 remote: npm ERR! npm ERR! path /tmp/npmcache.2vea7/_cacache/tmp/git-cloneBNIhGL/node_modules/node-sass remote: npm ERR! npm ERR! command failed remote: npm ERR! npm ERR! command sh -c node scripts/build.js

colincasey commented 2 years ago

@cstayyab I had no problem installing your fork of capturl using the git url:

git://github.com/cstayyab/capturl.git#main

Are you still having this problem?

colincasey commented 2 years ago

@KicksTV When using a git url, npm will clone the target dependency locally and run that project's install process. This means that git://github.com:KicksTV/dat.gui.git, in order to satisfy its dependency on rollup-plugin-sass, will attempt to compile node-sass@4.13.1 using node-gyp if there are no pre-built versions available.

That version of node-sass only includes pre-built binaries up to node v13 so that is why the node-gyp compile process is running. Modules that compile native addons may fail during Heroku deploy because that environment does not include the necessary C/C++ libraries or the architecture is not supported.