h2non / nar

node.js application archive - create self-contained binary like executable applications that are ready to ship and run
MIT License
428 stars 23 forks source link

Transitive dependencies not included #149

Open SimenB opened 7 years ago

SimenB commented 7 years ago

See https://github.com/finn-no/cdn-uploader

Doing npm run create-executable && chmod +x cdn-uploader-linux-x64.nar && ./cdn-uploader-linux-x64.nar exec -a meep ugh gives

module.js:471
    throw err;
    ^

Error: Cannot find module '@google-cloud/common'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/cdn-dir/node_modules/@google-cloud/storage/src/index.js:24:14)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)

@google-cloud/common is a dep of @google-cloud/storage.

algesten commented 7 years ago

doesn't look like google cloud common is a regular dependency of this package. are you sure it isn't installed by some funky post install script? https://github.com/GoogleCloudPlatform/google-cloud-node/blob/master/package.json

SimenB commented 7 years ago

It's a dep of storage: https://github.com/GoogleCloudPlatform/google-cloud-node/blob/0a3d926fdd7eec2e66b0048789baee9dac878412/packages/storage/package.json#L53

h2non commented 7 years ago

If the package is a runtime dependency of a dependant package in the node_modules tree, then it should be embedded accordingly in the nar archive.

Are you sure that the package has been installed properly and exists in node_modules/@google-cloud/storage?

I'm getting a native module compilation issue while installing that package (due to grpc installation).

h2non commented 7 years ago

I fix that issue using Python 2.7.

Looks like there's a bug here. That package should be resolved and embedded accordingly, but it does not.

As temporal workaround, I'd suggest creating explicitly adding @google-cloud/common as root level dependency in your package.json.

h2non commented 7 years ago

I can confirm that the above workaround solves the issue.

I will dig into details about why that dependency is not properly embedded, but my suspect is that this can be related to organization-based package naming issue.

SimenB commented 7 years ago

Cool, thanks for the workaround, I'll test it Monday 😄

SimenB commented 7 years ago

The workaround does work, thanks! Would of course prefer to avoid it, but it does work now, which is what matters 😄

h2non commented 7 years ago

Cool. Hopefully, I will have some time this weekend to fix the issue.

SimenB commented 7 years ago

@h2non Any news here? 😄

h2non commented 7 years ago

@SimenB unfortunately, not yet. I have other things in the queue, but will try to come up with a fix in the upcoming weeks.