GithubHelp home page GithubHelp logo

Comments (8)

kamilmysliwiec avatar kamilmysliwiec commented on April 28, 2024

#13146

TLDR; make sure you use the latest version (so the reflect-metadata version is in sync)

from nest.

moshicohen avatar moshicohen commented on April 28, 2024

Thanks, I have ran: npx npm-check-updates -u
but I still have the same problem.
Here are my updated dependencies:

"dependencies": {
    "@nestjs/common": "^10.3.3",
    "@nestjs/config": "^3.2.0",
    "@nestjs/core": "^10.3.3",
    "@nestjs/platform-express": "^10.3.3",
    "@nestjs/typeorm": "^10.0.2",
    "class-transformer": "^0.5.1",
    "class-validator": "^0.14.1",
    "pg": "^8.11.3",
    "reflect-metadata": "^0.2.1",
    "rxjs": "^7.8.1",
    "typeorm": "^0.3.20",
    "uuid": "^9.0.1",
    "winston": "^3.12.0"
  },
  "devDependencies": {
    "@nestjs/cli": "^10.3.2",
    "@nestjs/schematics": "^10.1.1",
    "@nestjs/testing": "^10.3.3",
    "@types/express": "^4.17.21",
    "@types/jest": "^29.5.12",
    "@types/node": "^20.11.24",
    "@types/supertest": "^6.0.2",
    "@types/uuid": "^9.0.8",
    "@typescript-eslint/eslint-plugin": "^7.1.1",
    "@typescript-eslint/parser": "^7.1.1",
    "eslint": "^8.57.0",
    "eslint-config-prettier": "^9.1.0",
    "eslint-plugin-prettier": "^5.1.3",
    "jest": "^29.7.0",
    "prettier": "^3.2.5",
    "source-map-support": "^0.5.21",
    "supertest": "^6.3.4",
    "ts-jest": "^29.1.2",
    "ts-loader": "^9.5.1",
    "ts-node": "^10.9.2",
    "tsconfig-paths": "^4.2.0",
    "typescript": "^5.3.3"
  },

from nest.

kamilmysliwiec avatar kamilmysliwiec commented on April 28, 2024

Please, provide a minimum reproduction repository.

You can also try removing the lock file & node_modules folder and re-running npm install

from nest.

moshicohen avatar moshicohen commented on April 28, 2024

So I have tried to provide a reproduction on Stackblitz, the problem is that it can't connect to DB so it throws an error an won't run. I can add once again my very basic app.controller and app.module.
regarding the deletion of node modules and re-run npm i - I have already done it and it didn't solve.
Thanks for your efforts !

my app.controller:


@Controller('app')
export class AppController {
  constructor(private readonly appService: AppService) {}

  @Get('/:id')
  getHello(@Param('id') id: string): string {
    console.log(id);
    return this.appService.getHello();
  }
}

my app.module:


@Module({
  imports: [
    UsersModule,
    ScheduleModule.forRoot(),
    CacheModule.register({ isGlobal: true }),
    HttpModule,
    ConfigModule.forRoot({
      isGlobal: true,
      envFilePath: ['.env.dev'],
    }),
    TypeOrmModule.forRootAsync({
      imports: [ConfigModule],
      inject: [ConfigService],
      useFactory: async (configService: ConfigService) => ({
        type: 'postgres',
        autoLoadEntities: true,
        synchronize: true,
        host: configService.get('DB_HOST'),
        port: configService.get('DB_PORT'),
        username: configService.get('DB_USERNAME'),
        password: configService.get('DB_PASSWORD'),
        database: configService.get('DB_DATABASE'),
      }),
    }),
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}

from nest.

phuffer avatar phuffer commented on April 28, 2024

For me @kamilmysliwiec's suggestion worked.

@moshicohen I updated my project to use all the dependencies you listed and my controller's still worked. Maybe inspect your package-lock.json and ensure the correct reflect-metadata version is being used and something else isn't pulling in 0.1.12.

from nest.

moshicohen avatar moshicohen commented on April 28, 2024

You are right guys, it was finally the version pf reflect-metadata.
When I ran: npx npm-check-updates -u it didn't update it.
I had to manually: npm install reflect-metadata@^0.2 and it solved it.
Thanks !

from nest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.