browserify-shim jquery-validate cannot find module

528 views Asked by At

I am trying to use browserify to manage the javascript, but I am blocked at the browserify-shim step.

The structure of my files is:

  • build:
    • package.json
    • gulpfaile.js
    • asset_src
      • bower_components
        • jquery-validate
          • dist
            • jquery-validate.js

In package.json I have the following:

browserify": {
    "transform": [
        "browserify-shim"
    ]
},
"browser": {
    "jquery": "./asset_src/bower_components/jquery/jquery.js",
    "validator": "./asset_src/bower_components/jquery-validate/dist/jquery.validate.js"
},
"browserify-shim": {
    "jquery": "$",
    "validator": {"depends": ["jquery"]}
}

And in a module I have:

var validator = require("validator");

I must be doing something wrong because whenever I use gulp to build, I get a message saying that the module "validator" is not found...

The jquery-validate attaches itself to the jQuery and to the $ on the window object. I have tried quite a few different variants of this, but this seems to be the most correct viewing the documentation... I really don#t know what else to try, so any indication in the right direction would be really apreciated!

All the best, Gioia

0

There are 0 answers