Skip to content

'nobuiltins' options is not working in certain circumstances #94

@Wh1teRabbitHU

Description

@Wh1teRabbitHU

Description

I found this bug yesterday. If npm install browserify not in the gulp-browserify 'node_modules' directory, but in your project's own one, the gulp task is throwing the following exception:

Error: Cannot find module './node_modules/browserify/lib/builtins.js'
  at Function.Module._resolveFilename (module.js:470:15)
  at Function.Module._load (module.js:418:25)
  at Module.require (module.js:498:17)
  at require (internal/module.js:20:19)
  at Transform.transform [as _transform] (<project-directory>/node_modules/gulp-browserify/index.js:81:22)
  (...)

The cause of the problem

It's pretty obvious from my description and from the stacktrace, but: The source code is searching for the builtins.js inside your module's directory, not the project's 'node_modules'.

Solution

You should check the file's existence. If it not exists, you should try to load it from ../node_modules/browserify/lib/builtins.js instead of ./node_modules/browserify/lib/builtins.js. I tried it, and worked in my case. The main concern is if the npm is using an another path combination to store the dependent browserify module directory. The advanced solution should determine where the module installed relative to your module and changing all your path depending on that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions