Skip to content
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

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

Closed
jamesnw opened this issue Mar 1, 2024 · 1 comment · Fixed by #2193
Closed

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

jamesnw opened this issue Mar 1, 2024 · 1 comment · Fixed by #2193
Assignees
Labels
bug JavaScript Issues particular to the Node.js distribution

Comments

@jamesnw
Copy link
Contributor

jamesnw commented Mar 1, 2024

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.

@ntkme
Copy link
Contributor

ntkme commented Mar 1, 2024

I think it's as easy as

-  } else if (process.argv case [_, String path]) {
+  } else if (process.argv case [_, String path, ...]) {

@nex3 nex3 added bug JavaScript Issues particular to the Node.js distribution labels Mar 4, 2024
@nex3 nex3 self-assigned this Mar 4, 2024
nex3 added a commit that referenced this issue Mar 12, 2024
nex3 added a commit that referenced this issue Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug JavaScript Issues particular to the Node.js distribution
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants