Skip to content

[Bug]: npx t3@nightly crashes from the 2nd run, it prunes the platform package's bundled node_modules (Cannot find module '@ff-labs/fff-node') #11736

Description

@varo6

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

Build, CI, or release tooling

Steps to reproduce

With an isolated npm cache so nothing else interferes:

CACHE=$(mktemp -d)
npx --cache "$CACHE" --yes t3@0.0.41-nightly.20260914.1700 --version   # 1st run: prints t3 v0.0.41-nightly.20260914.1700
npx --cache "$CACHE" --yes t3@0.0.41-nightly.20260914.1700 --version   # 2nd run: Error: Cannot find module '@ff-labs/fff-node'

Same thing without npx:

mkdir repro && cd repro && echo '{}' > package.json
npm install t3@0.0.41-nightly.20260914.1700   # t3 --version works
npm install                                    # "removed 11 packages"
npx t3 --version                               # Cannot find module '@ff-labs/fff-node'

Expected behavior

npx t3@nightly keeps working on every run, the way it did before the per-platform packages (#11607). In particular a systemd service with ExecStart=npx --yes t3@nightly serve ... and Restart=always should survive a restart.

Actual behavior

Only the first run after the package is extracted works. The platform package @t3code/t3-linux-x64 ships its runtime dependencies inside its own node_modules/ (published as a tarball on purpose, see the header of scripts/build-npm-platform-packages.ts). Those packages are not in the lockfile and not declared as bundleDependencies, so the next time npm reifies the same tree (the second npx in the same _npx cache dir, or any later npm install), Arborist treats them as extraneous and deletes them:

  • detect-libc, ffi-rs, msgpackr-extract, node-addon-api, node-gyp-build-optional-packages, node-pty are removed.
  • @ff-labs/, @msgpackr-extract/, @yuuang/ are left as empty directories.

The executable then crashes at startup on require('@ff-labs/fff-node'). With a service that has Restart=always, the first restart puts it into a permanent crash loop and the web UI is unreachable. Fixing it requires deleting the ~/.npm/_npx/<hash> directory, and it breaks again on the next restart.

#11607's verification ran npx -y t3@preview --version once per machine, which is the case that works. #11732 fixes a different upgrade break (missing t3/dist/bin.mjs) and does not touch this.

Impact

Blocks work completely

Version or commit

t3 0.0.41-nightly.20260914.1700 (@t3code/t3-linux-x64 0.0.41-nightly.20260914.1700). The preview packages (same layout since 0.0.41-preview.20260913.1669) are likely affected too; I only tested nightly.

Environment

Ubuntu 24.04.5 LTS x86_64, Node v24.14.0, npm 11.9.0. t3 runs as a systemd service: npx --yes t3@nightly serve --host 0.0.0.0 --port 3773 --no-browser.

Logs or stack traces

# 2nd npm install in the same tree
removed 11 packages in 237ms

$ ls node_modules/@t3code/t3-linux-x64/node_modules
@ff-labs  @msgpackr-extract  @yuuang
$ ls node_modules/@t3code/t3-linux-x64/node_modules/@ff-labs
(empty)

# service journal, the run right after the first successful start
Error: Cannot find module '@ff-labs/fff-node'
Require stack:
- ~/.npm/_npx/dec0da79062bfff0/node_modules/@t3code/t3-linux-x64/t3
    at Module._resolveFilename (node:internal/modules/cjs/loader:1569:15)
    ...
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '~/.npm/_npx/dec0da79062bfff0/node_modules/@t3code/t3-linux-x64/t3'
  ]
}
Node.js v26.8.2

Workaround

Pin the previous packaging, which declares these as normal dependencies: npx --yes t3@0.0.40 serve .... Alternatively delete ~/.npm/_npx/<hash> before every start (e.g. ExecStartPre), which forces a fresh extraction.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is broken or behaving incorrectly.via-triageFiled through npx t3 triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions