Meteor 1.3 - How to use npm package that is used in jquery like $(elem).package


#1

Hi, I installed two npm packages:

meteor npm install --save jquery
meteor npm install --save spectrum-colorpicker

Removed the atmosphere jquery package (meteor remove jquery)

But as spectrum is used like $(elem).spectrum(…) meteor advises that spectrum is unknown.

I have also tried to add an import of spectrum-colorpicker without success.

Anyone knows the solution? Thanks


#2

Issues like these are exactly why i am staying at 1.2.1

There is apparently no documentation on how to get these things resolved properly. I don’t understand how they say 1.3 is backwards compatible when it’s breaking for 90% of my projects.


#3

@ixdi
Don’t have exactly the same problem (still in process of updating to 1.3), but here some clues from official guide:

npm on the client

Tools like browserify and webpack are designed to provide a Node-like environment on the client so that many npm packages, even ones originally intended for the server, can run unmodified. Meteor’s ES2015 module system does this for you out of the box with no additional configuration necessary. In most cases, you can simply import npm dependencies from a client file, just as you would on the server.

When creating a new application Meteor installs the meteor-node-stubs npm package to help provide this client browser compatibility. If you are upgrading an application to Meteor 1.3 you may have to run meteor npm install --save meteor-node-stubs manually.


#4

I’ve installed meteor-node-stubs but nothing changed, result is the same: TypeError: $(…).spectrum is not a function
thanks, I’m using an atmosphere package, at least for now.


#5

Is jquery still in your .meteor/versions file?

Have you tried import { $ } from 'jquery' or are you just using the $ directly?


#7

Oh, and did you do require('spectrum-colorpicker'); somewhere in a client file?


#8

@tmeasday I’ve tried your recomendations but nothing changed…

jquery appear in .versions, as many packages need it and when I remove the name from the file it’s added again automatically.

Thanks


#9

This is a known issue. In 1.3.2, the jQuery package provided by Meteor core will be deprecated in favour of the official NPM version. Take a look at this issue for more details.


#10

Hey, this is still an issue in 1.3.2.4. Is there a way to use jQuery npm packages that are not using export?


#11

I don’t know if this works for you, but I need to add my jQuery plugins like this:

client/imports.js

import selectric from "selectric/public/jquery.selectric";
selectric(window,$);

#12

Late to the game here but I’m struggling with this as well. I’m attempting to use the package simplebar found here. All of the above recommendations have failed for me saying$(...).simplebar is undefined.

I have installed it with:

meteor npm install --save simplebar

The multiple ways of require() or import consistently fail.


#13

Hi, have you found a solution to this? I am right now going to the same issue. Thanks!


#14

Can please someone share a working solution on this?


#15

@tmeasday I can’t find a mention in the guid about how to do this. Jquery plugins fail on a new 1.3 project. (projects upgraded to 1.3 from 1.2 seem ok).


#16

import autogrow from “autogrow” seems to have worked for https://www.npmjs.com/package/autogrow, even though the variable autogrow is never used, it just runs the code that imports the proper functions in jquery.

(Just adding it now as I had to search for a while as well and ended up on this page full of questions!)


#17

Any solutions yet?
Some npm package something like datetimepicker is not imported or required still,
and I couldn’t make it.