-
Notifications
You must be signed in to change notification settings - Fork 262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
node-pre-gyp as non bundled dependency #162
Comments
Moving to |
We need to redefine |
@springmeyer , this works like a charm on my Windows machine: "scripts": {
"preinstall": "rem",
"postinstall": "node-pre-gyp install --fallback-to-build"
} Can you test something like this for Linux or Mac. (I'm not sure which dummy command is preferable in bash). |
The |
@rmg , my current solution (it tested on "scripts": {
"preinstall": " ",
"postinstall": "node-pre-gyp install --fallback-to-build"
} Can you propose something more elegant? |
@3y3 nothing more elegant, sorry. My point was just that you can use "scripts": {
"preinstall": " ",
"install": "node-pre-gyp install --fallback-to-build"
} |
@rmg - yes, but I think @3y3's point is that approach (the current, recommended approach) also necessitates |
@springmeyer , I switched to @rgm solution in production and it works fine. So there is no big difference between |
@3y3 - hmm, can you explain in more detail what your solution is? You've removed the bundling and added an empty |
Also, keep in mind that bundling is also needed when your app depends on more than one dependency packaged with node-pre-gyp. Otherwise if:
More details at #61 (comment) |
@springmeyer the empty The shared dependency case is a really good point, though. I hadn't thought of that. |
Reasonable. How about solution from #61
I don't say that this is a final solution, but this can be good start.
|
@3y3 that did not work when I tried it before. But it has been too long for me to remember why exactly. Reading my old comments I can see that multiple issues might have been confused. Another was that if node-pre-gyp is downloaded dynamically and shares deps those deps might also be dedupes and not available in time. However I think it is worth revisiting all this because I agree with you that is would be great to avoid the requirement. I don't have time to test all the scenarios right now so thanks for your efforts! |
Any other thoughts on this issue? I'm confused as to why package maintainers are forced to bundle node-pre-gyp as a dependency. This is problematic... if many native libs using node-pre-gyp live in the same project, there's a bunch of extra bloat (even if all those native libs require compatible versions of node-pre-gyp). Maybe as @3y3 mentioned, we can give package maintainers more options? |
Before npm v3, there was no guarantee that the required dependencies would be installed before the scripts run. Bundling is the only way to guarantee it in npm < 3.x. |
I'm confused. Why doesn't this work in the
This ensures |
Is it really true that prior to npm v3, deps are not guaranteed to be downloaded before scripts are run? I find that to be... weird and awful. Also, what about this? |
Mmm... I like
in |
Tested using |
I tried to do with for node-serialport and ended up with an endless pre-install loop when it was installed as a dependency. Anyone else have any issues? |
@reconbot not seen that, can you share the exact details of how to replicate? |
We published https://github.com/voodootikigod/node-serialport/blob/2.1.1/package.json You can still try to install it. |
@reconbot just tested and I cannot replicate a problem. The installs run fast and to completion. There is no hang or "endless loop". I tried both:
With both:
|
Can't (edited commit to make that more clear, sorry) |
@reconbot - any updates? I'm still not able to replicate and so I'm not aware of any problem. |
We're about to have another release, I've removed the extra rebuild script, so lets see what happens. |
Still seeing it with
|
@reconbot - Does this problem happen for the latest version of Node + NPM? |
I installed v0.12.7 with nvm on OSX, then upgraded npm with
But it eventually gets past that. Then the overall install fails with:
However I don't see this as related to node-pre-gyp. Seems like an npm bug to me. Both of the above problems go away if I do:
|
The ENOENT error looks like npm/npm#10995 |
I've taken another run at this. Its working on node 5 with npm 3.x, and node 0.12 and npm 2.x. But I see the loop with node 0.12 and npm 3x. I'm thinking it's an npm bug. I'm using kidrobot:tmp$ node -v
v0.12.7
kidrobot:tmp$ npm -v
3.8.8
kidrobot:tmp$ npm install voodootikigod/node-serialport#unbundle
> serialport@3.0.1 preinstall /Users/wizard/src/tmp/node_modules/.staging/serialport-a4f0ad8f
> npm install node-pre-gyp
> serialport@3.0.1 preinstall /Users/wizard/src/tmp/node_modules/.staging/serialport-a4f0ad8f/node_modules/.staging/serialport-13fe77f0
> npm install node-pre-gyp
> serialport@3.0.1 preinstall /Users/wizard/src/tmp/node_modules/.staging/serialport-a4f0ad8f/node_modules/.staging/serialport-13fe77f0/node_modules/.staging/serialport-074522d4
> npm install node-pre-gyp
> serialport@3.0.1 preinstall /Users/wizard/src/tmp/node_modules/.staging/serialport-a4f0ad8f/node_modules/.staging/serialport-13fe77f0/node_modules/.staging/serialport-074522d4/node_modules/.staging/serialport-2138bf23
> npm install node-pre-gyp
> serialport@3.0.1 preinstall /Users/wizard/src/tmp/node_modules/.staging/serialport-a4f0ad8f/node_modules/.staging/serialport-13fe77f0/node_modules/.staging/serialport-074522d4/node_modules/.staging/serialport-2138bf23/node_modules/.staging/serialport-01c0e617
> npm install node-pre-gyp
^C |
Hm, weird... thanks for submitting the npm issue, @reconbot ! We'll see what happens... |
Doing some more research and testing I've found that having |
It's also's https://github.com/mafintosh/prebuild#installing approach. |
Hey @3y3 you found a bug in the npm docs! https://docs.npmjs.com/misc/scripts#default-values conflicts with https://docs.npmjs.com/files/package.json#default-values Actually... tests indicate that if you overide either lifecycle method |
@reconbot - The @springmeyer - For clarification, could you explain the following:
Am I missing something? |
Lets test this, this is an easy test. I added @springmeyer's Next I cloned the @springmeyer I know you did a bunch of testing looking back in the thread. Everything I tested here was done locally. (not with remote packages) Perhaps you want to take a look too? |
I can confirm that specifying either a I'm going to release a beta of serialport without the preinstall or bundle and let people test. |
Thanks for putting up with me belaboring this closed issue for a few weeks. I think I'm finally done with exploring the options. @springmeyer was right to be concerned about modules being available. npm 2 (which still ships with node 4 LTS) does have a race condition when multiple packages require the same package, where the modules wont always be available during the install stage. I spoke with someone from npm about it, though I haven't found other docs or discussion about it. I got raised eyebrows from the npm cli team about installing in a For node serialport I'm going to stick with the bundled dependency for a while. At least until that npm bug is fixed for npm 3. We haven't had issues with that that weren't caused during publishing and we still have a lot of node 0.12 users. |
How I understand the main reason to bundle
node-pre-gyp
is a usage it on installation phase.And what happens if it will be used in
postinstall
step, is this resolves problem with bundling?Unfortunately I can't test this now, but maybe the answer is on the surface?
The text was updated successfully, but these errors were encountered: