Linking local node.js module inside local Meteor Package

血红的双手。 提交于 2019-12-25 07:01:45

问题


I'm in the process of developing a Meteor package, that has a dependency on a node module. This module is also, under development, so right now it's just a local folder.

Looking around, it seems that adding

Npm.depends({ "npmmodulename": "x.x.x"});

on the package.js file, it should be enough, but how do I do this, when the npm module is local? I tried adding the path to the module, instead of the version, but I had no luck...

Can this be actually done?


回答1:


You don't need to specify an Npm.depends clause because your node package is not yet published to npmjs.org so it doesn't matter.

Let's assume your node package is in "my-project/packages/my-package/node-package". You can reference it from your meteor package like this :

my-project/packages/my-package/server.js :

var nodePackage=Npm.require("../../../../../packages/my-package/node-package");

All the ../.. stuff is needed because the current working directory of a meteor node process is "my-project/.meteor/local/build/programs/server".

Note that using this technique, meteor doesn't take care of building your node package, so you need to manually "npm install" it each time you modify it's inner dependencies.



来源:https://stackoverflow.com/questions/21430119/linking-local-node-js-module-inside-local-meteor-package

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!