Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 of 4 tasks
rujorgensen opened this issue Dec 17, 2024 · 8 comments

Comments

@rujorgensen
Copy link

rujorgensen commented Dec 17, 2024

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/@[email protected]_@[email protected]_@[email protected]_@[email protected]_@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/@[email protected]_@[email protected]_@[email protected]_@[email protected]_@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/@[email protected]_@[email protected]_@[email protected]_@[email protected]_@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/@[email protected]_@[email protected]_@[email protected]_@[email protected]_@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/@[email protected]_@[email protected]_@[email protected]_@[email protected]_@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,
        ],
    };
});
@rujorgensen
Copy link
Author

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

@Coly010
Copy link
Contributor

Coly010 commented Dec 19, 2024

Hey @rujorgensen Could you provide a repo with a minimal reproduction of this so i can assist you further?

@itspers
Copy link

itspers commented Dec 20, 2024

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

adding output: {filename: '[name].js'} to config fixes it, but for me its still producing tone of errors, thinks for 20 seconds and time to time dies with some memory problem - seems for now 20.1.4 is the only way

@rujorgensen
Copy link
Author

Hi @Coly010, thanks for getting back, sorry for the delay--holidays and stuff 🎅.

So disclaimer first: while going through the steps of reproducing this, it appears there there are generally some issues with running the @nx/rspack conversion tool, which might have led to a bad setup in the first place, but this reproduces the issue

Reproduction

  1. Run npx [email protected] my-workspace --preset=nest (v. 20.1.4 was the version I migrated from originally)
  2. Add the @nx/rspack: cd my-workspace && nx add @nx/rspack
  3. Convert the webpack configuration to rspack: npx nx generate @nx/rspack:convert-webpack --project=my-workspace NOTE! This command now completes without touching any files. When I did this originally, it was many NX versions back, so I don't know when or why this stopped working. See steps below where I did this manually.
    This is the repo at this stage: https://github.com/rujorgensen/nx-rspack-issue
  4. ✅ Check that it runs (and main.js is generated in dist/apps/my-workspace): nx serve my-workspace
  5. Migrate the workspace to NX v. 20.2.2: nx migrate 20.2.2
  6. Install the updated dependencies and apply migrations: npm install && npx nx migrate --run-migrations
  7. 🛑 Run now fails as described in my opening post of this issue

Convert webpack config to rspack config (manually)

  1. Add rspack.config.js
const { composePlugins, withNx } = require('@nx/rspack');

module.exports = composePlugins(withNx(), (config) => config);
  1. Replace the "build"-target in apps/my-workspace/project.json with (this is what I have from an earlier @nx/rspack auto webpack -> rspack migration):
    "build": {
      "executor": "@nx/rspack:rspack",
      "outputs": [
        "{options.outputPath}"
      ],
      "defaultConfiguration": "production",
      "options": {
        "outputPath": "dist/apps/my-workspace",
        "main": "apps/my-workspace/src/main.ts",
        "tsConfig": "apps/my-workspace/tsconfig.app.json",
        "assets": [
          "apps/my-workspace/src/assets"
        ],
        "target": "node",
        "rspackConfig": "apps/my-workspace/rspack.config.js"
      },
      "configurations": {
        "development": {
          "mode": "development"
        },
        "production": {
          "mode": "production",
          "sourceMap": false
        }
      }
    }
  1. To get this to run, I have to delete the inferred target in nx.json (perhaps it has something to do with this)

Cheers!

Copy link

github-actions bot commented Jan 4, 2025

This issue has been automatically marked as stale because no reproduction was provided within 7 days.
Please help us help you. Providing a repository exhibiting the issue helps us diagnose and fix the issue.
Any time that we spend reproducing this issue is time taken away from addressing this issue and other issues.
This issue will be closed in 21 days if a reproduction is not provided.
If a reproduction has been provided, please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@github-actions github-actions bot added the stale label Jan 4, 2025
@rujorgensen
Copy link
Author

Bumping because a reproduction was provided, but the label was not changed causing the issue to be marked as stale by automation. @Coly010

@github-actions github-actions bot removed the stale label Jan 5, 2025
Copy link

This issue has been automatically marked as stale because no reproduction was provided within 7 days.
Please help us help you. Providing a repository exhibiting the issue helps us diagnose and fix the issue.
Any time that we spend reproducing this issue is time taken away from addressing this issue and other issues.
This issue will be closed in 21 days if a reproduction is not provided.
If a reproduction has been provided, please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@github-actions github-actions bot added the stale label Jan 12, 2025
@rujorgensen
Copy link
Author

Bumping again because a reproduction was provided, but the label was not changed causing the issue to be marked as stale by automation. @Coly010

@github-actions github-actions bot removed the stale label Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants