Skip to content

Browserify cannot browserify its own UMDs #1817

Closed

Description

@markandrus

I setup a project where index.js depends on a UMD. The source of the UMD lives in lib/. It will then be browserified and placed in dist/.

$ tree -I node_modules
.
├── index.js
└── lib
    ├── bar.js
    └── foo.js

1 directory, 3 files

I do this by executing the following:

$ mkdir /tmp/test
$ cd /tmp/test
$ npm install browserify
$ mkdir lib
$ cat >lib/foo.js <<EOF
> require('./bar');
> EOF
$ touch lib/bar
$ ./node_modules/.bin/browserify lib/foo.js -s Foo -o dist/foo.js
$ cat >index.js <<EOF
> require('./dist/foo');
> EOF

Then, I try to run browserify on index.js.

Expected Behavior

Browserify succeeds!

Actual Behavior

Browserify fails :-(

$ ./node_modules/.bin/browserify index.js -o dist/index.js
Error: Cannot find module './bar' from '/private/tmp/test/dist'
    at /private/tmp/test/node_modules/browser-resolve/node_modules/resolve/lib/async.js:55:21
    at load (/private/tmp/test/node_modules/browser-resolve/node_modules/resolve/lib/async.js:69:43)
    at onex (/private/tmp/test/node_modules/browser-resolve/node_modules/resolve/lib/async.js:92:31)
    at /private/tmp/test/node_modules/browser-resolve/node_modules/resolve/lib/async.js:22:47
    at FSReqWrap.oncomplete (fs.js:166:21)

Environment

Software Version(s)
Browserify 16.1.1
Node v9.2.0
npm 5.5.1
Operating System macOS

Activity

  1. goto-bus-stop commented on Mar 11, 2018

    @goto-bus-stop
    Member

    This issue is also reported here: #1773

    It will be fixed once browserify/detective#79 lands :)

  2. NHQ commented on Mar 18, 2022

    @NHQ

    I am using version 17 and have this same bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions