2013 Meteor NPM Packages

后端 未结 5 1041
青春惊慌失措
青春惊慌失措 2020-11-30 01:07

Update this solution describes how to effectively use the new Npm system in Meteor.


What is the current method of using NPM packages i

5条回答
  •  醉酒成梦
    2020-11-30 01:37

    The current way of using NPMs in Meteor

    1. Replace the x's below with the NPM name
    2. Place the files outline below in /meteor-project-root/packages/x/
    3. meteor add x
    4. To use it just call X in your code (X.function())

    x.js --------

    X = Npm.require('x');
    

    package.js --------

    Package.describe({
      summary: "Meteor smart package for x node.js package"
    });
    
    Npm.depends({
      "x": "0.1.1"
    });
    
    Package.on_use(function (api) {
      api.add_files("x.js", ["client", "server"]);
    });
    

    Note: some packages will only work on client or server, if you are having issues, try only include the side you are going to use it on.

提交回复
热议问题