Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

it possible use a nodejs package inside meteor app?

it posible use a nodejs package inside meteor app on server side? It would be great to do that since nodejs has a large number of packages.

like image 423
Topicus Avatar asked Jul 27 '12 16:07

Topicus


People also ask

Does meteor use node JS?

Meteor, or MeteorJS, is a partly proprietary, mostly free and open-source isomorphic JavaScript web framework written using Node. js. Meteor allows for rapid prototyping and produces cross-platform (Android, iOS, Web) code.

How use NPM package meteor?

To use an npm package from a file in your application you import the name of the package: import moment from 'moment'; // this is equivalent to the standard node require: const moment = require('moment'); This imports the default export from the package into the symbol moment .

How do I use Meteor packages?

To use an Atmosphere Package in your app you can import it with the meteor/ prefix: import { Mongo } from "meteor/mongo"; Typically a package will export one or more symbols, which you'll need to reference with the destructuring syntax. You can find these exported symbols by either looking in that package's package.

Which is used to include a package in a node JS application?

js Package Manager (npm) is the default and most popular package manager in the Node. js ecosystem, and is primarily used to install and manage external modules in a Node. js project. It is also commonly used to install a wide range of CLI tools and run project scripts.


1 Answers

Yes, it is possible. You can use an npm module in Meteor, since it's based on Node.js.

This code has worked for me fine, e.g.:

var fs = __meteor_bootstrap__.require('fs');

UPDATE: To install an npm module in a Meteor app

  1. Inside your terminal, change path to your Meteor app directory.
  2. > cd .meteor/local/build/server
  3. Install an npm module like so > npm install module_name.

 


 

Edit: for anyone visiting this post, it is outdated. As of Meteor 0.6.4, you use Npm.require instead of __meteor_bootstrap__.require:

var fs = Npm.require('fs');

Also, if you don't use standard node package, but one from npm repositories, it's better to create a dependency so that it's automatically installed every time you create a new instance of the project. To do so, create a /packages/someName/package.js file with the following line:

Npm.depends({'packageName': 'packageVersion'});
like image 65
nsmeta Avatar answered Oct 01 '22 07:10

nsmeta