Skip to content

Error resolving path when building bundle for browser with esbuild #268

Open

Description

I may be missing something obvious, but when I use istextorbinary and build for the browser, I get the following error:

 > node_modules/istextorbinary/edition-browsers/index.js:2:26: error: Could not resolve "path" (use "platform: 'node'" when building for node)
    2 │ import * as pathUtil from 'path';
      ╵                           ~~~~~~

Should it be importing from path?

Here's an example file test.ts:

import { isText } from "istextorbinary";
isText("test");

And here's what happens if you try to build it with esbuild --bundle:

$ esbuild test.ts --outfile=test.js --bundle
 > node_modules/istextorbinary/edition-browsers/index.js:2:26: error: Could not resolve "path" (use "--platform=node" when building for node)
    2 │ import * as pathUtil from 'path';
      ╵                           ~~~~~~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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