UnhandledRejection: The "path" argument must be of type string or an instance of URL. Received undefined
Freed-Wu opened this issue · 5 comments
Freed-Wu commented
import open from 'open';
//...
this.addAction('open', async (item: ListItem) => {
let status = 'succeed';
try {
await open(item.data.url);
} catch (e) {
status = 'failed';
}
window.showMessage(`${status} to open ${item.data.url}`);
});
After yarn build
, I test and get:
UnhandledRejection: The "path" argument must be of type string or an instance of URL. Received undefined
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of URL. Received undefined
at fileURLToPath (node:internal/url:1399:11)
at Object.<anonymous> (/the/path/lib/index.js:3627:84)
So I search /the/path/lib/index.js:3627:84
, and find:
// node_modules/open/index.js
var import_meta = {};
var __dirname = import_node_path.default.dirname((0, import_node_url.fileURLToPath)(import_meta.url));
The last line is 3627. It looks like a bug about node_modules/open/index.js
, So I report it.
ZomoXYZ commented
Removing the const __dirname = path.dirname(fileURLToPath(import.meta.url));
line from index.js
in my node_modules folder temporarily fixed this for me since the __dirname
variable is included with node by default. I found a similar issue on another repo and there the fix was to use __dirname
instead of import.meta.url
.