Skip to content

fix(cli): friendly error when package.json is missing#3935

Closed
isshaddad wants to merge 1 commit into
mainfrom
fix/cli-missing-package-json-message
Closed

fix(cli): friendly error when package.json is missing#3935
isshaddad wants to merge 1 commit into
mainfrom
fix/cli-missing-package-json-message

Conversation

@isshaddad

Copy link
Copy Markdown
Collaborator

Running trigger dev (or any command that runs the package update check) in a directory without a package.json crashed with a raw Cannot find matching package.json stack trace. This is because getPackageJson throws before the existing if (!packageJson) guard can run, so the guard was dead code.

Now it exits cleanly with an actionable message instead — telling the user to run from their project root, or to npm init -y and trigger.dev init if they haven't set up a project yet. The fix catches the throw at the call site in updateTriggerPackages; getPackageJson itself is unchanged (changing its return type rippled type errors into other callers).

Tested e2e via trigger update (same code path): no package.json → clean message + exit 1, package.json present → update check runs as before, version mismatch → still aborts as before.

@changeset-bot

changeset-bot Bot commented Jun 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 128db32

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 25 packages
Name Type
trigger.dev Patch
@trigger.dev/build Patch
@trigger.dev/core Patch
@trigger.dev/plugins Patch
@trigger.dev/python Patch
@trigger.dev/react-hooks Patch
@trigger.dev/redis-worker Patch
@trigger.dev/rsc Patch
@trigger.dev/schema-to-json Patch
@trigger.dev/sdk Patch
@trigger.dev/database Patch
@trigger.dev/otlp-importer Patch
@trigger.dev/rbac Patch
@internal/cache Patch
@internal/clickhouse Patch
@internal/llm-model-catalog Patch
@internal/redis Patch
@internal/replication Patch
@internal/run-engine Patch
@internal/schedule-engine Patch
@internal/testcontainers Patch
@internal/tracing Patch
@internal/tsql Patch
@internal/zod-worker Patch
@internal/sdk-compat-tests Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 506f5568-ea0b-4af6-ae6b-c2d3732987f8

📥 Commits

Reviewing files that changed from the base of the PR and between 8b40571 and 128db32.

📒 Files selected for processing (2)
  • .changeset/dev-missing-package-json-message.md
  • packages/cli-v3/src/commands/update.ts

Walkthrough

This PR improves error messaging when package.json is missing during trigger dev command execution. The updateTriggerPackages function in update.ts now wraps getPackageJson() in a try/catch block, throwing an OutroCommandError with actionable guidance when the file cannot be found, rather than relying on a destructuring pattern followed by a conditional null check. A corresponding changeset entry documents this patch-level user-facing behavior change.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/cli-missing-package-json-message

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@isshaddad isshaddad closed this Jun 12, 2026
@isshaddad isshaddad deleted the fix/cli-missing-package-json-message branch June 12, 2026 17:37
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

Successfully merging this pull request may close these issues.

1 participant