How can I deploy node modules in a Meteor app on meteor.com?

后端 未结 7 1579
轻奢々
轻奢々 2020-11-29 02:16

I have an application that uses the node twit module that is available via

npm install twit

I deployed the node module locally from .m

7条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-29 02:27

    This code worked for me with meteor 0.8.x and node_modules being installed in ./public of my app:

    var path = Npm.require('path')
    var fs = Npm.require('fs')
    var base = path.resolve('.')
    var isBundle = fs.existsSync(base + '/bundle')
    var modulePath = base + (isBundle ? '/bundle/static' : '/../client/app') + '/node_modules/'
    
    var twit  = Npm.require(modulePath+'rssparser')
    

    It may also be a good idea to create packages.json file within ./public for easier updates/installs through npm.

    Long live Meteor!

提交回复
热议问题