I started working on a NestJS application, the previous developer did not leave any documentation or comments and I'm new to NestJS and Node generally.
I'm having a hard time running the application locally, the application was developed using the following technologies: NestJS, GraphQL, apollo-server-express, Prisma.
First, I extracted the repo files and run the following commands (npm install
, npm run build
, npm run start
), I get the following error log:
Here are my npm scripts:
"build": "cross-env NODE_ENV=production webpack --progress --config webpack.config.prod.js",
"start:hmr": "node ./dist/server.js",
"start": "ts-node -r tsconfig-paths/register src/main.ts",
I tried changing the start script to
"start": "npm i -g @prisma/cli @nestjs/cli && prisma generate && node dist/main"
and still didn't work
main.ts
import 'source-map-support/register';
import { Env } from '@shared/utils';
import { AppModule } from '@app/app.module';
import { NestFactory } from '@nestjs/core';
import { ExpressAdapter, NestExpressApplication } from '@nestjs/platform-express';
import { HttpExceptionFilter } from '@shared/filters/http-exception.filter';
import { LoggerService } from '@shared/services';
import './seed';
const LOGGER = new LoggerService('Main');
const PORT: number = Env('PORT', 3000);
async function bootstrap() {
const app = await NestFactory.create<NestExpressApplication>(AppModule, new ExpressAdapter(), {
logger: LOGGER,
});
await app.useGlobalFilters(new HttpExceptionFilter()).listenAsync(PORT);
return PORT;
}
bootstrap()
.then(port => LOGGER.log(` Server ready at ${port}, started in ${process.uptime()}s`))
.catch(e => LOGGER.error(e.message, e));
Note: I have both Nest cli and npm installed globally. Thank you in advance.