Skip to content

cli fails ugly when running in a non-package #119

@Fuzzyma

Description

@Fuzzyma

If I run the analyze command in a folder that is not a package, it fails with really ugly error messages:

~ $ npx @e18e/cli analyze
e18e (cli v0.3.1)

┌  Analyzing...
node:internal/errors:983
  const err = new Error(message);
              ^

Error: Command failed: npm pack --pack-destination "/tmp/publint-pack-ZVhDic" --ignore-scripts
npm error code ENOENT
npm error syscall open
npm error path /home/ulima/package.json
npm error errno -2
npm error enoent Could not read package.json: Error: ENOENT: no such file or directory, open '/home/ulima/package.json'
npm error enoent This is related to npm not being able to find a file.
npm error enoent
npm error A complete log of this run can be found in: /home/ulima/.npm/_logs/2025-11-04T10_17_24_546Z-debug-0.log

    at genericNodeError (node:internal/errors:983:15)
    at wrappedFn (node:internal/errors:537:14)
    at ChildProcess.exithandler (node:child_process:414:12)
    at ChildProcess.emit (node:events:507:28)
    at maybeClose (node:internal/child_process:1101:16)
    at ChildProcess._handle.onexit (node:internal/child_process:305:5) {
  code: 254,
  killed: false,
  signal: null,
  cmd: 'npm pack --pack-destination "/tmp/publint-pack-ZVhDic" --ignore-scripts',
  stdout: '',
  stderr: 'npm error code ENOENT\n' +
    'npm error syscall open\n' +
    'npm error path /home/ulima/package.json\n' +
    'npm error errno -2\n' +
    "npm error enoent Could not read package.json: Error: ENOENT: no such file or directory, open '/home/ulima/package.json'\n" +
    'npm error enoent This is related to npm not being able to find a file.\n' +
    'npm error enoent\n' +
    'npm error A complete log of this run can be found in: /home/ulima/.npm/_logs/2025-11-04T10_17_24_546Z-debug-0.log\n'
}

We should catch that and give the user the feedback that they probably forgot to cd into the directory first :D

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions