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

Unclear Error Message When package.json Lacks version Key #241

Open
ElayGelbart opened this issue May 21, 2024 · 0 comments
Open

Unclear Error Message When package.json Lacks version Key #241

ElayGelbart opened this issue May 21, 2024 · 0 comments

Comments

@ElayGelbart
Copy link

When running various CLI commands using the yalc package, if the package.json file does not contain a version key, the resulting error message is unclear and misleading. It seems that the lack of a version key may not be properly handled, leading to an unexpected error in path operations.

Steps to Reproduce

Ensure package.json does not include a version key.
Run a CLI command such as yalc publish or yalc add.
Observe the error output.

Expected Behavior

The tool should either handle the missing version key gracefully by providing a clear error message indicating the absence of the version key or handle the operation assuming defaults.

Actual Behavior

The tool throws a TypeError related to path operations, which does not clearly communicate the issue related to the missing version key in package.json.

Error Output

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:399:5)
    at validateString (node:internal/validators:163:11)
    at Object.join (node:path:1172:7)
    at <file path removed for privacy>
    at new Promise (<anonymous>)
    at __awaiter (<file path removed for privacy>)
    at exports.copyPackageToStore (<file path removed for privacy>) {
  code: 'ERR_INVALID_ARG_TYPE'
}

(Note: File paths and user identifiers have been removed for privacy.)

Additional Information

Node version: v18.16.0
yalc version: 1.0.0-pre.53
Operating System: MacOS

Suggested Fix

A potential improvement could be to validate the existence of the version key before proceeding with operations that depend on it, and if it is missing, throw a clear and descriptive error message.

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

No branches or pull requests

1 participant