Using Packages article

This is the comment thread for the Using Packages article in the Meteor Guide.

Read the article: http://guide.meteor.com/using-packages.html

The comment thread for each article appears at the very bottom of the page. Use this thread to post:

  • Interesting articles related to the content
  • New ways to do things that aren’t covered in the Guide
  • Suggestions for Guide improvements

Or anything else related to this topic that people could find useful!

What is the correct way to import the Future object from fibers/future. I have the feeling that I should not be doing an npm install for the latest version, I should be using the version already packaged with Meteor instead.

I realize I can do:
const Future = Npm.require('fibers/future'),
but is Npm.require deprecated in favor of doing this somehow with es6 syntax?

The same question would go for accessing the raw MongoDB node driver packaged with Meteor…

Yes, I know I personally prefer to re-use npm modules from the Meteor dev_bundle. For this case, specifically, Npm.require()is fine. Advantages:

  • version consistency
  • smaller bundle to deploy

Of course in the longer term if these modules end up in package.json you’d want to switch.

I ran into what seems like a related problem when switching from an atmosphere package to an NPM package (uploadcare-widget). The package references images in the folder node_modules/uploadcare-widget/images. The images are displayed on the page via css, for example:

.uploadcare-dialog-file-sources:before {
  background-image: url("node_modules/uploadcare-widget/images/arrow.png");
}

I can see my app attempt to load the images from the network inspector, but the image doesn’t load from the displayed path. I can confirm that image files are in the specified file directory. Is there something special I need to do to be able to load images from an npm package?

I tried to follow this link: https://guide.meteor.com/using-npm-packages.html

installed using “meteor npm install --save moment”

but when I’m trying to use - import moment from ‘moment’;

I get an error: Module ‘“node_modules/moment/moment”’ has no exported member ‘moment’.

Any help is appreciated, thanks.

1 Like

Hi guys,

I haven’t messed around a lot with Promises, Fibrers and Async stuff yet and I really with there would be some more guidance in the guide.

I WISH there would be a sashko-quality (@sashko) best-practice summary of Start using async/await instead of promises and callbacks, especially dealing with Meteor.call()-related stuff. Just a bit more of details in the Promises example might really help saving some time and making the code more readable.

and

1 Like

In the discussion of npm shrinkwrap, Is “meteor npm install --save moment” just an example, or is it required by something (e.g. shrinkwrap or meteor). From the text, it appears that shrinkwrap requires moment…

Also, why does “meteor npm shrinkwrap” produce a bunch of “extraneous” messages that reference “node_modules\meteor-node-stubs\node_modules\minimatch” and what to do about them? The shrinkwrap.json file is not updated in this case, so I can’t just ignore these messages. But doing (for example) “meteor npm uninstall minimatch” doesn’t help.

Additional info: I just upgraded to meteor 1.5.1 from meteor 1.4.something, on Windows 8.1. “meteor npm shrinkwrap” worked for me on the previous version of meteor.

I’m having an odd issue with importing npm modules and would appreciate some guidance from people who know better. Before Meteor properly supported npm, the solution was to use Npm.require('libname'). Now that the support is in there, we’re supposed to just use require 'libname or import Lib from 'libname'.

However, there are a few npm packages where that fails. Our app uses googleapis, google-auth-library, and quickbase. When we bring in those libraries via import or require, we get weird errors that all go away when we drop back to using Npm.require. quickbase says we need to "use strict";, which seems like an ES5 issue we shouldn’t be having, while googleapis allegedly can’t be found in node_modules.

Our build system is mildly atypical because we’re using meteorcom:webpack (successor to webpack:webpack), not sure if that has anything to do with it.

Any ideas from the community? I never really understood what sort of magic Npm.require was doing under the hood, but it looks like it’s still occasionally necessary even though Meteor allegedly doesn’t need it anymore. Is there a good GitHub repo for me to leave this as an issue?

Meteor awesome would be cool. That is for example some of the dev packages are a must like constellation (babrahams…), compilation error overlays by stubailo, reval, compass mongo.