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.)
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.
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
(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.