Answer the question
In order to leave comments, you need to log in
Modules do not resolve when working on the server, but everything works locally. Why?
Всем привет!
Пилю бэкенд на nestjs (https://nestjs.com/). Запускаю npm run start. Локально все работает. Заливаю проект на удаленный сервер, запускаю node index.js, приложение стартует (ошибок нет), но как только запрос доходит до контроллера и пытается дернуть сервис, то вылетает ошибка типа TypeError: Cannot read property of undefined. Другими словами сервис не резолвится.
app.module.ts
import { Module } from '@nestjs/common';
import {AreaModule} from "./area/area.module";
@Module({
imports: [AreaModule]
})
export class AppModule {}
import { Module } from '@nestjs/common';
import {AreaController} from "./area.controller";
import {AreaService} from "./area.service";
@Module({
controllers: [AreaController],
components: [AreaService]
})
export class AreaModule {}
import {Body, Controller, Get, Post, Put, Req, Delete, Param} from '@nestjs/common';
import {AreaService} from './area.service';
import {Area} from "./interfaces/area.interface";
@Controller('area')
export class AreaController {
constructor(private readonly areaService: AreaService) {}
@Get()
async getAreas(@Req() request): Promise<Area[]> {
return this.areaService.getItems(request.query.sort);
}
}
import {Component} from '@nestjs/common';
import {Area} from "./interfaces/area.interface";
@Component()
export class AreaService {
getItems(sort: string): Promise<Area[]> {
return ...
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question