I have an executable file myutil.exe
which I call from my nodejs module to perform some functions.
I wish to package this up, publish my NodeJS module to npmjs.com and and the executable should be part of this nodejs library when used on this windows platform, since my nodejs code calls the executable to perform a function. I run this command line binary from nodejs already.
How to do this and how best to include this executable binary in this? should it be hosted outside of the package somehow?
Also note, its just a restriction, at this moment it must be an executable on windows, or an runnable binary on Linux systems due to the nature of the code inside of it, cannot be a DLL/library. Later perhaps I can move some of its code into a DLL/library.
supply a
bin
field in yourpackage.json
which is a map of command name to local file name. On install, npm will symlink that file intoprefix/bin
for global installs, or./node_modules/.bin/
for local installs.
For example, if you have this in the package.json
, and installed your package globally, the command npmputty
will be available in the PATH.
"bin": {
"npmputty": "./bin/putty.exe"
},
If you prefer to not release this executable in the package, it is possible to implement a postinstall
script to download it from somewhere like github.com.
{
"scripts" : {
"postinstall" : "scripts/download_from_github.js"
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With