Iperity / node-strophe

[?] A Node.js compatible version of Strophe.js, borrowed from https://github.com/dhruvbird/node-xmpp-bosh.
7 stars 12 forks source link

$ is not defined #1

Closed gauripadbidri closed 9 years ago

gauripadbidri commented 9 years ago

I have installed the node-strophe package within my NodeBB website. However I get an error '$ is not defined' even if I just include the following line of code : var strophe = require("node-strophe"); OR var strophe = require("node-strophe").Strophe;

Can anyone help me resolve this issue ?

tijszwinkels commented 9 years ago

Hi Gauripadbidri,

'$ is not defined' is usually caused by a missing jQuery include. However, I don't think that this error can be caused by node-strophe, as jQuery is not a dependency of node-strophe. Do you, by any chance, still get the error if you comment the whole require("node-strophe");. If so, the problem is elsewhere.

This is how we've included jQuery in one of our own node.js projects:

First install jquery and jsdom (needed to use jquery in node.js) as dependency from the command shell:

npm install jquery --save
npm install "jsdom@~0.2.15" --save

Then, load the $ symbol in your .js:

$ = require('jquery')(require("jsdom").jsdom().parentWindow);
gauripadbidri commented 9 years ago

Thanks for your reply....I get this error, the moment I have the following line in my code..The moment this line is commented out, I o not see any errors and my site runs well :

var strophe = require("node-strophe"); OR var strophe = require("node-strophe").Strophe;