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

nar create executable with npm rebuild? #119

Closed algesten closed 8 years ago

algesten commented 8 years ago

If I run nar under node 0.12.x on mac os x and do something like:

nar create --executable --os linux --arch x64 --node 5.1.0

What happens to the node-gyp compiled binaries? Will there be an npm rebuild once the archive has unpacked on the target platform?

h2non commented 8 years ago

Short answer: nar will embed the generated binaries of the current platform where the executable was built, so there will be incompatibility if you run the binary in other platform (or even in other incompatible node.js version).

Originally nar doesn't provide built-in support to deal with native addons. but I believe there're multiple choices to find a consistent solution.

One that just come to my mind could be as simple as defining a postinstall or prestart npm script in your package.json in order to run the proper npm command to rebuild those packages who uses platform specific native addons.

Give it a try and I will appreciate if you let me know if that solution is fine to you.

algesten commented 8 years ago

what we ended up doing is relying on .nvmrc so that our build script will do:

$ nvm install    # using .nvmrc for node version
$ nar create ...