The best way to add an npm package on meteor?

Hi,
I’d like to add an npm package, and I’ve been looking into Meteorhacks’ npm package, is this currently the best (=recommended) way to add npm packages to a meteor project?

1 Like

That’s probably the easiest way but I prefer the official way:

http://docs.meteor.com/#/full/Npm-depends

Mega simple example based on Maxpain177s work: https://github.com/benjick/meteor-steam-bot

3 Likes

Where would add the “Npm.depends” ?
Must I divide my project into packages (like one of the methods of folder structures) in order to write that inside the package.js or is there an alternative in case i’m using the classic client/, lib/, server/ folder structure?

See here https://github.com/benjick/meteor-steam-bot/blob/master/package.js#L14-L17

Yes, if you want to use Npm.depends you have to make it into a package.

While in your project directory type

meteor create --package my-package
meteor add my-package

Example output from my current project:

C:\dev\infoAdmin>meteor create --package my-package
my-package: created in packages\my-package

C:\dev\infoAdmin>meteor add my-package

Changes to your project's package version selections:

my-package  added, version 0.0.1


my-package

C:\dev\infoAdmin>
1 Like

I’m working on a package, rocket:module, that will be another way of using external libraries from npm, and writing entry points using CommonJS/AMD/ES6 Modules. More info in this post.