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

fix: avoid packageJson without name in resolveLibCssFilename #19324

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Jinjiang
Copy link
Contributor

Description

Fix the issue when there is no package name in package.json.

which causes errors like below:

[vite:css-post] Cannot read properties of undefined (reading '0')
[vite:css-post] Cannot read properties of undefined (reading '0')
    at getPkgName (/.../node_modules/vite/dist/node/chunks/dep-M1IYMR16.js:10488:14)
    at resolveLibCssFilename (/.../node_modules/vite/dist/node/chunks/dep-M1IYMR16.js:50127:30)

@patak-dev
Copy link
Member

Why does the package.json doesn't have a name? It is required:

A package.json file must contain "name" and "version" fields.

Maybe we should improve the error instead saying that the package.json is malformed?

@silverwind
Copy link

silverwind commented Jan 31, 2025

name and version may be required in the docs, but as far as the npm client is concerned {} is a valid package.json, so I suggest to treat is gracefully.

I think those requirements are only enforced for published packages.

@patak-dev patak-dev added the p3-minor-bug An edge case that only affects very specific usage (priority) label Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants