ilyo ilyo - 1 year ago 104
jQuery Question

how to use jQuery installed with npm in Express app?

I have a node.js + express app and I installed jQuery with npm.

in the

file I used

var jquery = require('jquery');

In the html file header I included javascript that uses jQuery and I get `jQuery is not defined'.
Is it a metter of order or am I missing something?

Answer Source

When you are installing jQuery with npm it's because you want to use jQuery on the server side of your application (Ex : in your app.js file). You still need to add jQuery to your web page like that :

<script src="//"></script>

If you want to use it on the client side. If you are using Jade, add the script tag to your template.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download