-
Notifications
You must be signed in to change notification settings - Fork 412
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
Include linux native module bindings in package #308
Comments
@joshhunt you have to use special loader for native modules, e.g. https://github.com/tec27/node-native-loader |
@joshhunt Thanks for asking. @pavelvlasov is right. You should use a proper webpack plugin or loader to get this done. Another one is the copy files plugin - see #205 (comment) Additionally, the options to include and exclude modules with the webpack plugin is: custom:
webpackIncludeModules:
forceInclude:
- sqlite3
- ...
forceExclude:
- ... See also the README. |
Thanks for the responses. It looks like copy-webpack-plugin (the original one, not the forked one) the trick to get it working. For reference, this is how I used it:
And it included the required files:
|
I'm using node-sqlite3 in a serverless.js function, and I'm having trouble getting serverless (or serverless-webpack - I'm not 100% sure where the problem lies) to package the correct native bindings.
Thankfully node-sqlite3 uses node-pre-gyp, so I'm able to download and install the required bindings locally on my mac. In my package.json, I have this postinstall script which handles this for me.
And I can prove that the bindings are present on my machine, which is exactly what I want
However once I run
serverless package
(and prevent the.webpack
folder from being removed),I notice that the
node-v48-linux-x64
bindings folder doesn't get copiedIt's also not in the zip archive in
.serverless
:In these above cases, I need the
node-v48-linux-x64/node_sqlite3.node
file to also be packaged across.How can I ensure that
node_modules/sqlite3/lib/binding/node-v48-linux-x64/**
is included in the final package? I've tried using thepackage.include[]
option in serverless.yml, however that doesn't work. I've also tried addingsqlite3/lib/binding/node-v48-linux-x64/node_sqlite3.node
as an entrypoint in the webpack config, but it's still not copied across.How can I fix this?
The text was updated successfully, but these errors were encountered: