2

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.

Thanks

2 Answers 2

3

You can install jQuery on your server like that:

npm install jquery

And then you need to declare your jQuery variable like this:

var $ = require('jQuery');

Now you can use jQuery like you are used too. More information here.

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

5 Comments

My second line of code will load it. Put it in the top of your server.js for example. It’s build like a Node.js module, like Express and so on…
OK, I did it. It says it cannot find module location.
prob, you giving wrong path for jquery. change this line //var $ = require('jQuery');
Be sure to install the module with npm. My first line of code. You have to do it on your computer/server etc. Npm is a tool to manage Node modules.
I did install it. I had to drag the folder, though, from a place to my wamp folder.
0

You can load it as text and eval(jquery) will let you use jquery

1 Comment

if you eval a js text like eval("var jq=function(){return 4;}"); this will let you use jq function. So you can use it for jquery file. But if there is plug-in for jq ofcourse its better usage. But this is less code =D

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.