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”;
};
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:
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?
I tried your solution:
- dev.nix file
- 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
Don’t know if you’re still running into this issue, but I was able to get my app building (it’s in the app
directory) with this (I think I needed the $PORT variable and 0.0.0.0
host specified):
previews = {
enable = true;
previews = {
web = {
command = ["npm" "run" "dev" "--" "--port" "$PORT" "--host" "0.0.0.0"];
manager = "web";
cwd = "app";
};
};
};