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/Node Generates Broken Applications: Serve Fails to Locate Main.js (v20.3) #29480

Open
1 of 4 tasks
Lamar1806 opened this issue Dec 28, 2024 · 1 comment
Open
1 of 4 tasks

Comments

@Lamar1806
Copy link

Current Behavior

Current Behavior

The nx build command works and generates the necessary output files in the expected directory. However, running the nx serve command fails with the following error:

[ watch ] build succeeded, watching for changes...
/Users/dalmarsegrest-brooks/Documents/Code.nosync/Ikigai/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 /Users/dalmarsegrest-brooks/Documents/Code.nosync/Ikigai/dist/apps/night-owl-server/main.js. Make sure your build succeeded.
    at fileToRunCorrectPath (/Users/dalmarsegrest-brooks/Documents/Code.nosync/Ikigai/node_modules/@nx/js/src/executors/node/node.impl.js:312:11)
    at /Users/dalmarsegrest-brooks/Documents/Code.nosync/Ikigai/node_modules/@nx/js/src/executors/node/node.impl.js:98:49
    at new Promise (<anonymous>)
    at Object.start (/Users/dalmarsegrest-brooks/Documents/Code.nosync/Ikigai/node_modules/@nx/js/src/executors/node/node.impl.js:92:36)
    at async Timeout.processQueue [as _onTimeout] (/Users/dalmarsegrest-brooks/Documents/Code.nosync/Ikigai/node_modules/@nx/js/src/executors/node/node.impl.js:63:13)

The main.js file exists in the dist/apps/night-owl-server directory after running the build command, but the serve command is unable to locate it.


Expected Behavior

The nx serve command should:

  1. Trigger the nx build command to generate the necessary files.
  2. Locate the generated main.js file in the dist/apps/night-owl-server directory and execute it.

This behavior is expected for a newly generated Node.js application.


Steps to Reproduce

  1. Clone the repository and checkout the night-owl-server branch:

    git clone https://github.com/Lamar1806/Ikigai.git
    cd Ikigai
    git checkout night-owl-server
  2. Install dependencies:

    npm install
  3. Build the application:

    nx build night-owl-server
  4. Verify that the build generates the main.js file in the correct directory:

    ls dist/apps/night-owl-server
  5. Serve the application:

    nx serve night-owl-server --verbose
  6. Observe the error:

    [ watch ] build succeeded, watching for changes...
    /Users/dalmarsegrest-brooks/Documents/Code.nosync/Ikigai/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 /Users/dalmarsegrest-brooks/Documents/Code.nosync/Ikigai/dist/apps/night-owl-server/main.js. Make sure your build succeeded.
    

Failure Logs / Images / Videos

Error Logs:

[ watch ] build succeeded, watching for changes...
/Users/dalmarsegrest-brooks/Documents/Code.nosync/Ikigai/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 /Users/dalmarsegrest-brooks/Documents/Code.nosync/Ikigai/dist/apps/night-owl-server/main.js. Make sure your build succeeded.
    at fileToRunCorrectPath (/Users/dalmarsegrest-brooks/Documents/Code.nosync/Ikigai/node_modules/@nx/js/src/executors/node/node.impl.js:312:11)
    at /Users/dalmarsegrest-brooks/Documents/Code.nosync/Ikigai/node_modules/@nx/js/src/executors/node/node.impl.js:98:49
    at new Promise (<anonymous>)
    at Object.start (/Users/dalmarsegrest-brooks/Documents/Code.nosync/Ikigai/node_modules/@nx/js/src/executors/node/node.impl.js:92:36)
    at async Timeout.processQueue [as _onTimeout] (/Users/dalmarsegrest-brooks/Documents/Code.nosync/Ikigai/node_modules/@nx/js/src/executors/node/node.impl.js:63:13)

Environment

  • Nx Console version: (Specify if applicable)
  • VSCode version: 1.96.2
  • Nx version: 20.3.0
  • Node.js version: 23.4.0
  • OS: macOS

nx report Output:

>  NX  Report complete - copy this into the issue template

  Node : 23.4.0
  OS   : macOS
  npm  : 9.8.0
  
  nx : 20.3.0
  @nrwl/js : 20.3.0
  @nrwl/node : 20.3.0
  @nx/esbuild : 20.3.0

Additional Notes

Expected Behavior

Explained above

GitHub Repo

https://github.com/Lamar1806/Ikigai/tree/night-owl-server

Steps to Reproduce

Steps to Reproduce

  1. Clone the repository and checkout the night-owl-server branch:

    git clone https://github.com/Lamar1806/Ikigai.git
    cd Ikigai
    git checkout night-owl-server
  2. Install dependencies:

    npm install
  3. Build the application:

    nx build night-owl-server
  4. Verify that the build generates the main.js file in the correct directory:

    ls dist/apps/night-owl-server
  5. Serve the application:

    nx serve night-owl-server --verbose
  6. Observe the error:

    [ watch ] build succeeded, watching for changes...
    /Users/dalmarsegrest-brooks/Documents/Code.nosync/Ikigai/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 /Users/dalmarsegrest-brooks/Documents/Code.nosync/Ikigai/dist/apps/night-owl-server/main.js. Make sure your build succeeded.
    

Nx Report

NX   Report complete - copy this into the issue template

Node           : 23.4.0
OS             : darwin-arm64
Native Target  : aarch64-macos
npm            : 10.9.2

nx (global)            : 20.3.0
nx                     : 20.3.0
@nx/js                 : 20.3.0
@nx/jest               : 20.3.0
@nx/eslint             : 20.3.0
@nx/workspace          : 20.3.0
@nx/cypress            : 20.3.0
@nx/detox              : 20.3.0
@nx/devkit             : 20.3.0
@nx/esbuild            : 20.3.0
@nx/eslint-plugin      : 20.3.0
@nx/express            : 20.3.0
@nx/module-federation  : 20.3.0
@nx/node               : 20.3.0
@nx/playwright         : 20.3.0
@nx/plugin             : 20.3.0
@nx/react              : 20.3.0
@nx/react-native       : 20.3.0
@nx/vite               : 20.3.0
@nx/web                : 20.3.0
@nx/webpack            : 20.3.0
typescript             : 5.6.3
---------------------------------------
Registered Plugins:
@nx/react-native/plugin
@nx/eslint/plugin
@nx/vite/plugin
@nx/cypress/plugin
@nx/playwright/plugin
---------------------------------------
Local workspace plugins:
         @ikigai/workspace-extensions

Failure Logs

> nx run night-owl-server:serve:development

[ watch ] build succeeded, watching for changes...
/Users/dalmarsegrest-brooks/Documents/Code.nosync/Ikigai/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 /Users/dalmarsegrest-brooks/Documents/Code.nosync/Ikigai/dist/apps/night-owl-server/main.js. Make sure your build succeeded.
    at fileToRunCorrectPath (/Users/dalmarsegrest-brooks/Documents/Code.nosync/Ikigai/node_modules/@nx/js/src/executors/node/node.impl.js:312:11)
    at /Users/dalmarsegrest-brooks/Documents/Code.nosync/Ikigai/node_modules/@nx/js/src/executors/node/node.impl.js:98:49
    at new Promise (<anonymous>)
    at Object.start (/Users/dalmarsegrest-brooks/Documents/Code.nosync/Ikigai/node_modules/@nx/js/src/executors/node/node.impl.js:92:36)
    at async Timeout.processQueue [as _onTimeout] (/Users/dalmarsegrest-brooks/Documents/Code.nosync/Ikigai/node_modules/@nx/js/src/executors/node/node.impl.js:63:13)

Node.js v23.4.0

Package Manager Version

No response

Operating System

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

Additional Information

@Lamar1806 Lamar1806 changed the title NX Serve Fails to Locate Main.js in Freshly Generated Node Application (v20.3) NX/Node Generates Broken Applications: Serve Fails to Locate Main.js (v20.3) Dec 28, 2024
@Lamar1806
Copy link
Author

Is it possible for me to get an update on when you guys will be able to fix this?

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

1 participant