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

Module '"node_modules/json5/lib/index"' has no default export #287

Open
AndreKR opened this issue Aug 18, 2022 · 1 comment
Open

Module '"node_modules/json5/lib/index"' has no default export #287

AndreKR opened this issue Aug 18, 2022 · 1 comment
Assignees
Labels

Comments

@AndreKR
Copy link

AndreKR commented Aug 18, 2022

If I import like this:

import JSON5 from 'json5';

PhpStorm shows me an error:

Module '"node_modules/json5/lib/index"' has no default export.

And indeed there is no export default in index.d.ts (that's the file PhpStorm will jump to when I Ctrl-click 'json5').

Vite can build the application though.


If I import like this:

import { parse } from 'json5';

I get no error in PhpStorm but Vite gives me an error:

The requested module '/node_modules/.vite/deps/json5.js?t=1660861994334&v=ed192948' does not provide an export named 'parse'


If I import like this:

import * as JSON5 from 'json5';

I get an error at runtime:

JSON5.parse is not a function

@jordanbtucker
Copy link
Member

Looks like vite is using the module field in package.json, which points to dist/index.mjs, which has a default export but no named exports. This is the same issue as #240. I think I have a fix for it that won't introduce any breaking changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants