I need to make a native C API available to my Meteor app, but as a first step, I followed the Hello World Node.js example for C/C++ Addon
here: https://nodejs.org/api/addons.html
I did meteor npm install node-gyp
.
Then, at the top level of my Meteor project, I created addons/hello
, and copy and pastes the hello.cc
and binding.gyp
files.
Then I did the node-gyp’s configure and build steps and can see the file addons/hello/build/Release/addon.node
.
In server/main.js
, I have code
Meteor.startup(() => {
console.log(“Server started”);
const addon = require(’…/addons/hello/build/Release/addon’);
console.log(addon.hello());
});
When I run meteor, I get the error:
I20161104-14:23:14.060(-7)? Server started
W20161104-14:23:14.149(-7)? (STDERR) /xxx/.meteor/packages/meteor-tool/.1.4.1_2.tw7mp8++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:280
W20161104-14:23:14.149(-7)? (STDERR) throw(ex);
W20161104-14:23:14.149(-7)? (STDERR) ^
W20161104-14:23:14.150(-7)? (STDERR)
W20161104-14:23:14.150(-7)? (STDERR) Error: Cannot find module '…/addons/hello/build/Release/addon’
W20161104-14:23:14.150(-7)? (STDERR) at require (packages/modules runtime/.npm/package/node_modules/install/install.js:85:1)
W20161104-14:23:14.150(-7)? (STDERR) at server/main.js:16:19
W20161104-14:23:14.150(-7)? (STDERR) …
However, if I delete the addons/hello/build/Release/addon.node
file, and create a simple JS module instead: addons/hello/build/Release/addon.js
, my app finds the module, and loads it fine.
What am I missing?
Environment: Ubuntu 14.04 + Meteor 1.4.1.2