We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
process.argv[1]
new NodePackageImporter()
1 parent 32a8dfe commit e6be3a3Copy full SHA for e6be3a3
lib/src/importer-registry.ts
@@ -2,6 +2,7 @@
2
// MIT-style license that can be found in the LICENSE file or at
3
// https://opensource.org/licenses/MIT.
4
5
+import {createRequire} from 'module';
6
import * as p from 'path';
7
import {URL} from 'url';
8
import {inspect} from 'util';
@@ -21,6 +22,10 @@ export class NodePackageImporter {
21
22
? p.resolve(entryPointDirectory)
23
: require.main?.filename
24
? p.dirname(require.main.filename)
25
+ : // TODO: Find a way to use `import.meta.main` once
26
+ // https://github.com/nodejs/node/issues/49440 is done.
27
+ process.argv[1]
28
+ ? createRequire(process.argv[1]).resolve(process.argv[1])
29
: undefined;
30
if (!entryPointDirectory) {
31
throw new Error(
0 commit comments