Reputation:
I installed jQuery and it is not my question:
npm install jquery
I try to include jQuery library into my page like this:
var jQuery = require('jquery'); or
import jQuery from "jquery";
and get in Chrome console:
Uncaught ReferenceError: $ is not defined
How can I overcome it?
Upvotes: 0
Views: 4589
Reputation: 21785
In my cases the following works well:
global.jQuery = require('jquery');
global.$ = global.jQuery;
or if you prefer "window" or it is obviously present, then:
typeof window !== "undefined" ? window : this;
window.jQuery = require('jquery');
window.$ = window.jQuery;
Upvotes: 2
Reputation: 5708
You have to use:
var $ = require('jquery');
or
import $ from 'jquery';
Upvotes: 6