You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running nx run user-service:serve from the project root, I encounter an error after updating from [email protected] to nx@latest. However, executing the same command from the workspace root works correctly. This issue wasn't present with [email protected].
The issue seems to appears only in nest project, I tested react project Its not happening.
Expected Behavior
To enable running nx nest targets not only from the workspace root but also from the project root.
Create a new workspace with [email protected], using [email protected], including one nest project in service/user-service and one react project with Module Federation in platform/ui-host and platform/ui-remote.
# Create a new workspace
npx [email protected]#(No Stack, Integrated Monorepo)
yarn
# Add the following plugins
nx add @nx/react
nx add @nx/express
nx add @nx/nest
nx add @nx/node
nx add @nx/plugin
nx add @nx/cypress
# Generate the host project (not really related to the issue)
nx generate @nx/react:host --name=ui-host --directory=platform/ui-host --e2eTestRunner=none --unitTestRunner=jest --minimal=true --projectNameAndRootFormat=as-provided --setParserOptionsProject=true --style=none --no-interactive
nx generate @nx/cypress:configuration --project=ui-host --setParserOptionsProject=true --no-interactive
# Generate the remote project (not really related to the issue)
nx generate @nx/react:remote --name=ui-remote --directory=platform/ui-remote --host=ui-host --e2eTestRunner=none --projectNameAndRootFormat=as-provided --setParserOptionsProject=true --style=none --unitTestRunner=jest --no-interactive
nx generate @nx/cypress:configuration --project=ui-remote --setParserOptionsProject=true --no-interactive
# Generate the nest project
nx g @nx/nest:application user-service --directory=services/user-service --projectNameAndRootFormat=as-provided
Run nx run user-service:serve in the root of the workspace or in the service/user-service directory. The nest project will start successfully.
Run nx run user-service:serve in the root will work fine. But running the same command in the service/user-service directory will throw the following error:
Debugger attached.
Waiting for the debugger to disconnect...
/Users/super.user/Documents/Workspaces/nx-issue-cwd/node_modules/@nx/js/src/executors/node/node.impl.js:331
throw new Error(`Could not find ${fileToRun}. Make sure your build succeeded.`);
^
Error: Could not find dist/services/user-service/main.js. Make sure your build succeeded.
at fileToRunCorrectPath (/Users/super.user/Documents/Workspaces/nx-issue-cwd/node_modules/@nx/js/src/executors/node/node.impl.js:331:11)
at /Users/super.user/Documents/Workspaces/nx-issue-cwd/node_modules/@nx/js/src/executors/node/node.impl.js:114:49
at new Promise (<anonymous>)
at Object.start (/Users/super.user/Documents/Workspaces/nx-issue-cwd/node_modules/@nx/js/src/executors/node/node.impl.js:108:36)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async processQueue (/Users/super.user/Documents/Workspaces/nx-issue-cwd/node_modules/@nx/js/src/executors/node/node.impl.js:79:13)
Node.js v20.12.2
Waiting for the debugger to disconnect...
Note: I only added react project to reflect my nx workspace setup. There is no direct link with react project.
Debugger attached.
Waiting for the debugger to disconnect...
/Users/super.user/Documents/Workspaces/nx-issue-cwd/node_modules/@nx/js/src/executors/node/node.impl.js:331
throw new Error(`Could not find ${fileToRun}. Make sure your build succeeded.`);
^
Error: Could not find dist/services/user-service/main.js. Make sure your build succeeded.
at fileToRunCorrectPath (/Users/super.user/Documents/Workspaces/nx-issue-cwd/node_modules/@nx/js/src/executors/node/node.impl.js:331:11)
at /Users/super.user/Documents/Workspaces/nx-issue-cwd/node_modules/@nx/js/src/executors/node/node.impl.js:114:49
at new Promise (<anonymous>)
at Object.start (/Users/super.user/Documents/Workspaces/nx-issue-cwd/node_modules/@nx/js/src/executors/node/node.impl.js:108:36)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async processQueue (/Users/super.user/Documents/Workspaces/nx-issue-cwd/node_modules/@nx/js/src/executors/node/node.impl.js:79:13)
Node.js v20.12.2
Waiting for the debugger to disconnect...
It appears to be related to the workspace root. When printing the fileToRun value here, I'm getting an absolute path in nx@18, but a relative path in nx@20.
Current Behavior
When running
nx run user-service:serve
from the project root, I encounter an error after updating from [email protected] to nx@latest. However, executing the same command from the workspace root works correctly. This issue wasn't present with [email protected].The issue seems to appears only in
nest
project, I tested react project Its not happening.Expected Behavior
To enable running nx nest targets not only from the workspace root but also from the project root.
GitHub Repo
https://github.com/MisterPandaPooh/nx-cwd-issue
Steps to Reproduce
[email protected]
, using[email protected]
, including one nest project in service/user-service and one react project with Module Federation in platform/ui-host and platform/ui-remote.Run
nx run user-service:serve
in the root of the workspace or in the service/user-service directory. The nest project will start successfully.Migrate to
nx@latest
.nx run user-service:serve
in the root will work fine. But running the same command in the service/user-service directory will throw the following error:Note: I only added react project to reflect my nx workspace setup. There is no direct link with react project.
Nx Report
Failure Logs
Package Manager Version
[email protected]
Operating System
Additional Information
⚠ Interesting observation: ⚠
It appears to be related to the workspace root. When printing the
fileToRun
value here, I'm getting an absolute path in nx@18, but a relative path in nx@20.Additionally, when I make this small change in the getFileToRun function on line 407, the issue seems to be resolved.
The text was updated successfully, but these errors were encountered: