4

After running npm install jquery, what then? I have tried:

import $ from "jquery.js";
var $ = require("jquery.js");

This code is in my app.js file which is connected to my html. jQuery code I write has no affect on the DOM.

ksingh
  • 154
  • 4
  • 10

1 Answers1

4

Just use it like this:

import $ from 'jquery';

$(function () {
  // ...
});

If you use express add this as static route

app.use('/lib/jquery', express.static(path.join(__dirname, 'node_modules/jquery/dist')));

And load it in your html file:

<script src="/lib/jquery/jquery.min.js"></script>

Maybe you have to modify the pathes.

tom
  • 9,550
  • 6
  • 30
  • 49
  • You don't need to move the jQuery.min.js file. The static route loads it from the node_modules. – tom Oct 10 '19 at 17:11