Skip to content

run the compiled app #31330

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

Open
1 of 4 tasks
its-dibo opened this issue May 25, 2025 · 0 comments
Open
1 of 4 tasks

run the compiled app #31330

its-dibo opened this issue May 25, 2025 · 0 comments

Comments

@its-dibo
Copy link

Current Behavior

I switched my monorepo to NX, previously the package.json file had some scripts, after building the app the package.json file also copied into dist.
Now I can deploy the dist dir of each app separately and run something like npm run start from it

Now everything is changed. I removed the scripts section from package.json and added empty targets in project.json in each app, and defined the target defaults in nx.json

my-app/project.json

{
 targets:{
   build: {},
  serve: {}
 }

nx.json

targetDefaults:{
  build:{
    // ....
  },
 serve:{
  dependsOn: ['build'],
  // ...
}
}

Now when I build the app and copy package.json into dist and upload the dist dir, it has no scripts
I tried to copy both the root nx.json and the project's project.json, but not worked, also, in my local machine, nx see that I have duplicate workspaces, also I want to test serving the app from dist as I'll do after deploying it
i.e. runnng nx run-many -t serve will build the app from the source ode, and then serve it, which is not the desired behavior to test how the compiled app will run on the server after deploying it

Expected Behavior

I can run npm start to serve the compiled app without building from the source, and without deploying the souce code at all

GitHub Repo

No response

Steps to Reproduce

  1. Add nx to n existing monorepo
  2. Define the targetDefaults in the root nx.json
  3. Define the targets (can be empty or merged with targetDefaults) in the project's project.json
  4. Remove the scripts section from package.json
  5. Build the app
  6. deploy or upload the dist dir and run npm start, the start command is not defined in package.json

Nx Report

Node           : 22.12.0
OS             : linux-x64
Native Target  : x86_64-linux
pnpm           : 9.15.0

nx (global)  : 21.1.2
nx           : 21.1.0
@nx/js       : 21.1.0
@nx/jest     : 21.1.0
@nx/eslint   : 21.1.0
typescript   : 5.8.3
---------------------------------------
Registered Plugins:
@nx/js/typescript
--------------------------------------

Failure Logs

Package Manager Version

pnpm

Operating System

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

Additional Information

No response

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