Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p><a href="http://info.meteor.com/blog/announcing-meteor-1.3" rel="nofollow noreferrer">Meteor 1.3</a>, released on March 28, 2016, gives apps full ES6 (ES2015) modules support and out of the box NPM support. Apps and packages can now load NPM modules directly and easily on the client and on the server.</p> </blockquote> <p>If you can use 1.3, then check <a href="http://guide.meteor.com/using-packages.html#installing-npm" rel="nofollow noreferrer">http://guide.meteor.com/using-packages.html#installing-npm</a>.</p> <p>For example, to use moment.js:</p> <pre><code>meteor npm install --save moment </code></pre> <p>Then in your code:</p> <pre><code>import moment from 'moment'; // this is equivalent to the standard node require: const moment = require('moment'); </code></pre> <p>If you need to use an older version of Meteor, read the rest of the answer below.</p> <hr> <p><strong>Pre-Meteor 1.3</strong>:</p> <p><a href="http://www.meteor.com/blog/2013/04/04/meteor-060-brand-new-distribution-system-app-packages-npm-integration" rel="nofollow noreferrer">Since v0.6.0, Meteor integrates directly with NPM modules</a> with the help of a 3rd party package. For example, to use a module like <a href="https://npmjs.org/package/ws" rel="nofollow noreferrer"><code>ws</code></a>,</p> <ol> <li>Run <code>sudo npm install -g ws</code> (or for local installs, see <a href="https://stackoverflow.com/questions/10587964/where-do-we-put-node-modules-we-install-by-npm-in-a-meteor-project">this</a>)</li> <li><p>In your sever JavaScript file,</p> <pre><code>var Websocket = Npm.require('ws'); var myws = new Websocket('url'); </code></pre></li> </ol> <p>To use a core Node module, just make the corresponding <code>Npm.require()</code> call, e.g. <code>var Readable = Npm.require('stream').Readable</code>.</p> <hr> <p>You can use any of the more than <a href="https://www.npmjs.com/" rel="nofollow noreferrer">230,000 NPM modules</a> directly with Meteor thanks to the <a href="http://meteorhacks.com/complete-npm-integration-for-meteor.html" rel="nofollow noreferrer">NPM package</a> developed by Arunoda.</p> <p>You can also define dependencies on Npm packages from smart packages - from <a href="https://groups.google.com/d/msg/meteor-talk/b6zQrgk8lYo/7KykCwz19WMJ" rel="nofollow noreferrer">the initial announcement</a> of npm support:</p> <p>Your smart package can now define dependencies directly, by adding a call to <code>Npm.depends</code> in <code>package.js</code>:</p> <pre><code>Npm.depends({ "awssum": "0.12.2", "underscore.string": "2.3.1" }); </code></pre> <p>All of this works well with hot code reload, just like the rest of Meteor. When you make changes, the bundler will automatically download missing npm packages and re-pin its dependencies.</p> <p>To use an NPM module within server code, use <code>Npm.require</code> as you would normally use plain <code>require</code>. Notably, <code>__meteor_bootstrap__.require</code> has been eliminated and all of its uses have been converted to <code>Npm.require</code>.</p> <p>There is <a href="https://github.com/avital/meteor-xml2js-npm-demo" rel="nofollow noreferrer">a small example of using an NPM module in your application</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload