1

I am running browserify for an app.js located at some path and it fails everytime with cannot find module lodash from [PATH].

Running "browserify:build" (browserify) task
Error: Cannot find module 'lodash' from '/var/lib/jenkins/buildcode/output/mydir/app_store_richUI/cartridge/js'
Warning: Error running grunt-browserify. Use --force to continue.

The [PATH] is same where the app.js file is present. But, if I change the file name to some other js file at same path, it works. So, the scene is that it succeeds for some js file and fails for others at same path.

Can someone suggest something ?

I have the Browserify.js script installed globally.

Browserify.js

module.exports = {
        build: {
            files: {
                '<%= settings["local.build.dir"] %>/output/<%= grunt.config("build") %>/app_eyeconic_richUI/cartridge/static/default/js/eyeconic.app.js':'<%= settings["local.build.dir"] %>/output/<%= grunt.config("build") %>/app_eyeconic_richUI/cartridge/js/app.js'
            },
        }
    
}

The path is shown correctly in the logs with other files. It fails only with app.js file

Community
  • 1
  • 1
jazz199
  • 911
  • 1
  • 8
  • 12
  • What does your `app.js` look like? How do you run browserify? – silvenon Jul 31 '15 at 10:49
  • Here is my app.js [link](https://drive.google.com/file/d/0B6aCHPw9hVVCYmt2c1liQnBUYm8/view?usp=sharing) . I am just running grunt browserify with the browserify config file given above. Strange thing is if i provide any other file instead of app.js at the same path, it works. Which means that path is not a problem here – jazz199 Jul 31 '15 at 11:04
  • Then where does it get `lodash` from? What does that `require` statement look like? Are you sure you have `lodash` installed? – silvenon Jul 31 '15 at 14:17
  • lodash is installed. i have it in node_modules folder. And i am not sure where to check the require statement. Very new to grunt as such. The thing is i could not find in the task browserify or the app.js that where it is requiring lodash. Plus the very same files work if i provide any other file – jazz199 Aug 01 '15 at 18:21
  • Anyone knows about this issue? – jazz199 Aug 03 '15 at 06:36

1 Answers1

1

It was a very trivial issue but took quite some time to resolve. The issue was that the build suite was at a different location than the build source. The browserify task contained require statements and it searches for modules in the parent directories so it was not able to find the required module.

After copying the build suite at the same path as the source, it worked.

So currently, my gruntfile.js(and other files/folders in the suite), exports and output directory at are same path.

jazz199
  • 911
  • 1
  • 8
  • 12