Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
2 of 4 tasks
ArcMichael opened this issue Mar 6, 2022 · 2 comments
Closed
2 of 4 tasks
Labels
bug Something isn't working needs triage

Comments

@ArcMichael
Copy link

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

@ArcMichael ArcMichael added bug Something isn't working needs triage labels Mar 6, 2022
@ArcMichael
Copy link
Author

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

@kamilmysliwiec
Copy link
Member

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

@nestjs nestjs locked and limited conversation to collaborators Mar 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working needs triage
Projects
None yet
Development

No branches or pull requests

2 participants