nrwl/nx

NX v. 20.2.2 migration with rspack causes "throw new Error(`Could not find ${fileToRun}. Make sure your build succeeded.`);"

Opened this issue · 1 comments

Current Behavior

Serving NestJS application with RSPack configuration, fails with "throw new Error(Could not find ${fileToRun}. Make sure your build succeeded.);"
^

This happened after the latest NX migration to v. 20.2.2, which updates "@nx/rspack" to v. "20.2.2" too. Downgrading "@nx/rspack" to v. 20.1.4, appears to fix the issue.

Expected Behavior

I expect the app to serve like before the migration.

GitHub Repo

No response

Steps to Reproduce

  1. I ran nx migrate latest, then applied the migration
  2. Serve the app nx serve backend-server

Nx Report

Node           : 20.11.1
OS             : linux-x64
Native Target  : x86_64-linux
pnpm           : 9.10.0

nx (global)            : 20.0.0
nx                     : 20.2.2
@nx/js                 : 20.2.2
@nx/jest               : 20.2.2
@nx/eslint             : 20.2.2
@nx/workspace          : 20.2.2
@nx/angular            : 20.2.2
@nx/cypress            : 20.2.2
@nx/devkit             : 20.2.2
@nx/eslint-plugin      : 20.2.2
@nx/express            : 20.2.2
@nx/module-federation  : 20.2.2
@nx/nest               : 20.2.2
@nx/node               : 20.2.2
@nx/plugin             : 20.2.2
@nx/rspack             : 20.2.2
@nx/storybook          : 20.2.2
@nx/vite               : 20.2.2
@nx/web                : 20.2.2
@nx/webpack            : 20.2.2
typescript             : 5.6.3
---------------------------------------
Registered Plugins:
@nx/eslint/plugin
---------------------------------------
Community plugins:
@fortawesome/angular-fontawesome : 0.15.0
@ionic/angular                   : 8.4.1
@ngneat/spectator                : 19.0.0
@nxext/ionic-angular             : 17.0.1
@storybook/angular               : 8.4.7
angular-eslint                   : 19.0.2
ng-mocks                         : 14.13.1
---------------------------------------
Local workspace plugins:
         @project-name/workspace-plugin

Failure Logs

(node:92088) DeprecationWarning: A 'callback' argument needs to be provided to the 'rspack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback.
(Use `node --trace-deprecation ...` to show where the warning was created)
●  ━━━━━━━━━━━━━━━━━━━━━━━━━ (100%) emitting after emit                                                                                                                                                           
chunk (runtime: main) main.46afa6f5135ce981.js (main) 4.02 MiB (javascript) 982 bytes (runtime) [entry] [rendered]
Rspack compiled successfully (f48b85e3058beb99)
Watcher closed
/home/name/company-name/project-name-wsl/node_modules/.pnpm/@nx+js@20.2.2_@babel+traverse@7.25.9_@swc-node+register@1.10.9_@swc+core@1.9.3_@swc+helpers@0_jw6tco35l7zktrglrqwqwwneaq/node_modules/@nx/js/src/executors/node/node.impl.js:312
    throw new Error(`Could not find ${fileToRun}. Make sure your build succeeded.`);
          ^

Error: Could not find /home/name/company-name/project-name-wsl/dist/apps/backend/server/main.js. Make sure your build succeeded.
    at fileToRunCorrectPath (/home/name/company-name/project-name-wsl/node_modules/.pnpm/@nx+js@20.2.2_@babel+traverse@7.25.9_@swc-node+register@1.10.9_@swc+core@1.9.3_@swc+helpers@0_jw6tco35l7zktrglrqwqwwneaq/node_modules/@nx/js/src/executors/node/node.impl.js:312:11)
    at /home/name/company-name/project-name-wsl/node_modules/.pnpm/@nx+js@20.2.2_@babel+traverse@7.25.9_@swc-node+register@1.10.9_@swc+core@1.9.3_@swc+helpers@0_jw6tco35l7zktrglrqwqwwneaq/node_modules/@nx/js/src/executors/node/node.impl.js:98:49
    at new Promise (<anonymous>)
    at Object.start (/home/name/company-name/project-name--wsl/node_modules/.pnpm/@nx+js@20.2.2_@babel+traverse@7.25.9_@swc-node+register@1.10.9_@swc+core@1.9.3_@swc+helpers@0_jw6tco35l7zktrglrqwqwwneaq/node_modules/@nx/js/src/executors/node/node.impl.js:92:36)
    at async Timeout.processQueue [as _onTimeout] (/home/name/company-name/project-name--wsl/node_modules/.pnpm/@nx+js@20.2.2_@babel+traverse@7.25.9_@swc-node+register@1.10.9_@swc+core@1.9.3_@swc+helpers@0_jw6tco35l7zktrglrqwqwwneaq/node_modules/@nx/js/src/executors/node/node.impl.js:63:13)

Node.js v20.11.1

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

Running on Windows in WSL.

This is the contents of the rspack.config.js of the application.

const { composePlugins, withNx } = require('@nx/rspack');

module.exports = composePlugins(withNx(), (config) => {
    return {
        ...config,
        ignoreWarnings: [
            /Critical dependency:/, warning => false,
            /HarmonyLinkingWarning/, warning => false,
            /Resolve error/, warning => false,
        ],
    };
});

The serve-command expects a file called main.js to be produced in the dist-folder, but after the update to 20.2.2, produces a file with fingerprinting:

Before update:
Image

After update:
Image