nestjs/schedule

Cannot find module '@nestjs/schedule' or its corresponding type declarations.

ArcMichael opened this issue · 2 comments

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

[8/9] RUN nest build:
#12 17.86 src/app.module.ts:4:32 - error TS2307: Cannot find module '@nestjs/schedule' or its corresponding type declarations.
#12 17.86
#12 17.86 4 import { ScheduleModule } from '@nestjs/schedule';
#12 17.86 ~~~~~~~~~~~~~~~~~~
#12 17.86 src/app.service.ts:2:26 - error TS2307: Cannot find module '@nestjs/schedule' or its corresponding type declarations.
#12 17.86
#12 17.86 2 import { Interval } from '@nestjs/schedule';
#12 17.86 ~~~~~~~~~~~~~~~~~~
#12 17.86
#12 17.87 Found 2 error(s).
#12 17.87

Minimum reproduction code

https://github.com/nestjs/schedule.git

Steps to reproduce

NODE_VERSION=16.14.0
APP_NAME=nestjs-api
APP_VERSION=0.0.7-rc.0
NODE_ENV=production
APP_PORT=3000

version: '3.8'

services:
node:
container_name: ${APP_NAME}
image: ${APP_NAME}:${APP_VERSION}
build:
context: .
dockerfile: Dockerfile.dev
command: npm run start:prod
ports:
- 3000:3000
restart: unless-stopped

FROM node:16.14.0

WORKDIR /usr/src/app

ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}

COPY . /usr/src/app/

RUN npm config set loglevel http

npm install glob

RUN npm install @nestjs/cli -g

npm install dependency

RUN npm install

RUN npm run build

COPY . .

CMD ["node", "dist/main"]

Expected behavior

src/app.module.ts

import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';

import { ScheduleModule } from '@nestjs/schedule';

@module({
// imports: [ScheduleModule.forRoot()],
imports: [ScheduleModule.forRoot()],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}

app.service.ts

import { Injectable } from '@nestjs/common';
import { Interval } from '@nestjs/schedule';
// import { Cron, CronExpression } from '@nestjs/schedule';

@Injectable()
export class AppService {
getHello(): string {
return 'Hello World!';
}

// @Cron(CronExpression.EVERY_30_SECONDS)
@interval(10000)
handleCron() {
console.log('Test');
}
}

Package version

8.1.3

NestJS version

No response

Node.js version

No response

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

I refer to "https://docs.nestjs.com/techniques/task-scheduling" and properly installed @ nestjs/schedule and @ types/cron, but why I didn't find installed plug-ins will prompt

Please, use our Discord channel (support) for such questions. We are using GitHub to track bugs, feature requests, and potential improvements.