New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UnhandledRejection: The "path" argument must be of type string or an instance of URL. Received undefined #330
Comments
Removing the |
@sindresorhus is a fix in sight for this? |
The problem is with people's bundler config, not this package. There is nothing to fix here. |
This is my import fs from "fs";
import * as esbuild from "esbuild";
const loadJSON = (path) =>
JSON.parse(fs.readFileSync(new URL(path, import.meta.url)));
const data = loadJSON("package.json");
const options = {
entryPoints: ["src/index.ts"],
bundle: true,
minify: process.env.NODE_ENV === "production",
sourcemap: process.env.NODE_ENV === "development",
mainFields: ["module", "main"],
external: ["coc.nvim"],
platform: "node",
target: "node16",
outfile: data.main,
};
if (process.argv.length > 2 && process.argv[2] === "--watch") {
const ctx = await esbuild.context(options);
await ctx.watch();
console.log("watching...");
} else {
const result = await esbuild.build(options);
if (result.errors.length) {
console.error(result.errors);
}
} |
I was able to fix it by adding the following lines to my esbuild options: define: { 'import.meta.url': '_importMetaUrl' },
banner: {
js: "const _importMetaUrl=require('url').pathToFileURL(__filename)",
}, |
After
yarn build
, I test and get:So I search
/the/path/lib/index.js:3627:84
, and find:The last line is 3627. It looks like a bug about
node_modules/open/index.js
, So I report it.The text was updated successfully, but these errors were encountered: