Skip to content

Node Package Importer can't find ESM entry point if args are provided #2188

@jamesnw

Description

@jamesnw

Currently, it appears that an entryPoint is only found if argv has exactly 2 arguments.

I'm observing this in a Vite project, with the css key in vite.config.ts setting up the package importer using the legacy API-

css: {
    preprocessorOptions: {
      scss: {
        includePaths: [path.resolve('./src/sass/')],
        pkgImporter: new NodePackageImporter(),
      },
    },
  },

Running yarn vite works, but yarn vite dev fails with the The Node package importer cannot determine an entry point because require.main.filename is not defined. error. Stepping through sass.dart.js in the debugger, I can see that the value of process.argv contains 3 values, and so if (process.argv case [_, String path]) does not match.

We have worked around this issue by providing "." as an entry point to the NodePackageImporter.

Metadata

Metadata

Assignees

Labels

JavaScriptIssues particular to the Node.js distributionbug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions