How to set previews for a nestjs proejct that resides inside a direectory

I have a nestjs project like this directory
main_project
- idx
- nest_project
- all nestjs files
when I run npm run start:dev then it starts running. How can I get UI of this project or how should I configure my previews config inside dev.nix?

You can specify cwd in your preview config. Let us know if that works!

web = {
command = [“npm” “run” “start:dev” ];
manager = “web”;
cwd = “path/to/project”;
};

2 Likes

I tried this solution and the web preview start and open without errors, but never stop starting and not show my expected message output.

I am running a nestjs project. The server port is 3000. My dev.nix file looks like:

image

The logs output show no errors too, but I can’t display the web view with expected message

The main.ts file has the code:

import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  await app.listen(3000);
}
bootstrap();

The $PORT variable is set internally. Can you remove “PORT” from the env block, and also listen on process.env.PORT instead of 3000 in main.ts please?

1 Like

I tried your solution:

  • dev.nix file

image

  • main.ts file

… And the preview for the webapp is (still the same output):

I ran the webapp changing the port number from 3000 to 9002 (the port number who print out the console) when start the app