4-point-0 / raidar-backend

Raidar api services that empower Raidar app for musicians and creators to buy and sell music licenses
0 stars 0 forks source link

Error running `yarn run migration:generate` #43

Open mgsmyth opened 3 months ago

mgsmyth commented 3 months ago

Trying to set up Postgres in AWS RDS, but I'm hitting an error during the nest build part of the yarn run migration:generate command (output below).

I ran yarn install successfully first on my local machine. I tried upgrading @types/cron to the latest version 2.4.0 instead of 2.0.1, but the output is the same. Please advise on next steps.

Output:

yarn run v1.22.22
$ nest build
error TS2688: Cannot find type definition file for 'cron'.
  The file is in the program because:
    Entry point for implicit type library 'cron'
src/modules/task/task.service.ts:72:19 - error TS2345: Argument of type 'import("/Users/meghan/Workspace/raidar/raidar-backend/node_modules/cron/dist/time").CronTime' is not assignable to parameter of type 'import("/Users/meghan/Workspace/raidar/raidar-backend/node_modules/@nestjs/schedule/node_modules/cron/types/index").CronTime'.
  The types returned by 'sendAt().setZone(...)' are incompatible between these types.
    Type 'import("/Users/meghan/Workspace/raidar/raidar-backend/node_modules/cron/node_modules/@types/luxon/src/datetime").DateTime<true> | import("/Users/meghan/Workspace/raidar/raidar-backend/node_modules/cron/node_modules/@types/luxon/src/datetime").DateTime<false>' is not assignable to type 'luxon.DateTime<true> | luxon.DateTime<false>'.
      Type 'DateTime<true>' is not assignable to type 'DateTime<true> | DateTime<false>'.
        Type 'import("/Users/meghan/Workspace/raidar/raidar-backend/node_modules/cron/node_modules/@types/luxon/src/datetime").DateTime<true>' is not assignable to type 'luxon.DateTime<true>'.
          Types of property 'diff' are incompatible.
            Type '(otherDateTime: import("/Users/meghan/Workspace/raidar/raidar-backend/node_modules/cron/node_modules/@types/luxon/src/datetime").DateTime<boolean>, unit?: import("/Users/meghan/Workspace/raidar/raidar-backend/node_modules/cron/node_modules/@types/luxon/src/duration").DurationUnits, opts?: import("/Users/meghan/Works...' is not assignable to type '(otherDateTime: luxon.DateTime<boolean>, unit?: luxon.DurationUnits, opts?: luxon.DiffOptions) => luxon.Duration<true>'.
              Types of parameters 'otherDateTime' and 'otherDateTime' are incompatible.
                Type 'DateTime<boolean>' is missing the following properties from type 'DateTime<boolean>': getPossibleOffsets, isWeekend, localWeekday, localWeekNumber, and 2 more.

72       job.setTime(new CronTime(cronTime));
                     ~~~~~~~~~~~~~~~~~~~~~~
src/modules/task/task.service.ts:86:36 - error TS2345: Argument of type 'CronJob' is not assignable to parameter of type 'CronJob<null, null>'.

86         cronJobs.push(mapCronToDto(value, key));
                                      ~~~~~
src/modules/task/task.service.ts:101:57 - error TS2345: Argument of type 'CronJob' is not assignable to parameter of type 'CronJob<null, null>'.
  Type 'CronJob' is missing the following properties from type 'CronJob<null, null>': cronTime, unrefTimeout, lastExecution, runOnce, and 3 more.

101       return new ServiceResult<CronJobDto>(mapCronToDto(job, name));
                                                            ~~~

Found 4 error(s).

error Command failed with exit code 1.
rimatik commented 3 months ago

Hmmm, what version of yarn are you using locally? Try to delete node_modules locally and run yarn install again and run yarn build If this goes well than in order to populate production database you have to change locally env file, add these variables:

MODE="production" DATABASE_HOST="raidar-dev.cp78qof4mguj.eu-central-1.rds.amazonaws.com" - put yours DATABASE_PORT=5432 DATABASE_NAME="raidar-testnet" - your db name DATABASE_USER="postgres" - this is default one, if you named it different change DATABASE_PASSWORD="yourpassword" - put yours

in package json change migration:run script to yarn build && MODE=production yarn typeorm migration:run -d src/common/config/db/orm.config.ts and run that script, afterward change to local values

mgsmyth commented 3 months ago

I am running yarn v1.22.22

I removed node_modules and ran yarn install, which worked well. But I hit the same error reported above when I ran yarn build after that.

rimatik commented 2 months ago

Would be good to migrate yarn to new version before call, check migration guide here https://yarnpkg.com/migration/guide

mgsmyth commented 2 months ago

I migrated to berry (4.4.1) as that guide recommends, but I got the exact same error. Then I migrated to version 3.6.3 as Ivor recommended, and I'm still hitting the same error.