node.js - Shimming jQuery nodes for browserify -


i have file requires module installed npm:

-- login.js -- require('jquery-form'); 

the module relies on jquery variable existing in window scope i'm browserifying this, understand need shim it. i've installed browserify-shim , using (from package.json):

"browserify-shim": {   "./node_modules/jquery/dist/jquery.js": "jquery" },  

however, when jquery-form runs, jquery not defined. missing?

you need "shim" jquery dependency of jquery-form. if these installed via npm there no need browser directive. because jquery-form doesn't have main directive in package.json need add browser directive show browserify file include in bundle.

"browserify-shim": {   "jquery-form": {     "depends": ["jquery"] }, "browserify": {   "transform": [ "browserify-shim" ] }, "browser": {   "jquery-form": "./node_modules/jquery-form/jquery.form.js" }, 

see this section of docs.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -