Skip to content

Forward/Backward slash mismatch for external requires on Windows #1613

Description

@ollyhayes

To reproduce, create two files - /scripts/lib.js & /scripts/index.js, with index.js requiring libs.js

Then run the following from the root directory:

browserify -r ./scripts/lib.js > ./scripts/lib-bundle.js
browserify -x ./scripts/lib.js ./scripts/index.js > ./scripts/index-bundle.js

Then load in a browser:

<script src="/scripts/lib-bundle.js"></script>
<script src="/scripts/index-bundle.js"></script>

...and we get the following error: Uncaught Error: Cannot find module '/scripts\lib.js'.

Inspecting the output files, we see the following files are exporting/requiring the following paths:

platform version lib-bundle.js exports index-bundle.js requires works
Windows >=12.0.2 /scripts/lib.js /scripts\\lib.js no
Windows <=12.0.1 /scripts\\lib.js /scripts\\lib.js yes
Linux any /scripts/lib.js /scripts/lib.js yes

Activity

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