2

I saw:

https://groups.google.com/forum/#!topic/meteor-core/ZlPPrH7SqrE

http://guaka.org/guaka-jquery-meteor-server-side-try-var-meteor-bootstrap-requirejquery-javascript-0

Server-side jquery

How can one parse HTML server-side with Meteor?

And I have not figured out a way to include jQuery in Meteor server side. Anyone knows?

I tried:

Npm.require('jquery')
Npm.require('jQuery')

But package is not found:

# Npm.require('jquery')
►[Error][Error: Cannot find module 'jquery']
Community
  • 1
  • 1
sites
  • 21,417
  • 17
  • 87
  • 146

2 Answers2

2

Try using this package https://github.com/meteorhacks/npm

  1. Run $: meteor add meteorhacks:npm
  2. in packages.json specify npm package and it's version { "jquery": 2.1.1 }
  3. Require jQuery Meteor.npmRequire("jquery");
  4. fire up your server $: meteor
Marek Takac
  • 3,002
  • 25
  • 30
0

For Meteor 1.0

Create .meteor/package.json with:

{
  "dependencies":{
    "jquery": "*"
  }
}

Then cd .meteor and run npm install to install jquery in .meteor/node_modules.

Then you can use in server Npm.require('jquery').

And add node_modules in .meteor/.gitignore so you don't push dependencies that will be installed with npm install.

There is a problem though, npm does not keep track versions of installed packages. To do that, run npm shrinkwrap in .meteor, that way, when another developer run npm install in another machine will get the same version you installed.

sites
  • 21,417
  • 17
  • 87
  • 146
  • Wouldn't it be enough just to specify the exact version of jQuery in `package.json`? I mean instead of running `npm shrinkwrap` – Marek Takac Nov 03 '14 at 19:16