1

I'm using node.js and socket.io and doing a server/client thing. On my Server, is since its' not on a webpage, is there a way I can load the latest file (or latest jQuery?) so I can use jQuery functions inside my Server js file.

I tried doing npm install jquery then drag the jquery folder into my node_modules folder onto my website. Then at he top of my file I put var $ = require('jQuery'); and then I run it and I get the error Cannot find module 'location'

Thanks

8
  • have you tried node-jquery plugin? Commented May 16, 2012 at 19:54
  • Sounds like somewhere you're referencing a "location" module. That has nothing to do with jQuery. Find where the error is at and determine whether you actually need "location" or whether you're not including it properly. Commented May 16, 2012 at 19:55
  • Yes @Raminson, that is what I am doing now. Commented May 16, 2012 at 19:57
  • @ChrisPratt Funny because if I take out the var $ = require('jQuery') it goes away.. Here's my error: i.imgur.com/vVCOO.png Commented May 16, 2012 at 20:04
  • Why do you need jQuery in node.js? Commented May 16, 2012 at 22:20

1 Answer 1

1

I was getting this same issue. I created a small test applications (with express), installed jquery afresh and things started working.

Checking my initial project a couple of changes seemed significant

  1. I did an npm unisntall for jquery and jsdom
  2. I did an npm install jquery (note, lowercase)
  3. I changed my require('jQuery') to be require('jquery') (again, lowercase)

I think the significant part was removing and reinstalling jsdom and jquery but the others then were required to get things working again.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.