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.
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.
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 .
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.
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.
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
> cd .meteor/local/build/server
> 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'});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With