Get Instant Solutions for Kubernetes, Databases, Docker and more
NestJS is a progressive Node.js framework for building efficient, reliable, and scalable server-side applications. It leverages TypeScript and is heavily inspired by Angular, making it a popular choice for developers familiar with Angular's architecture. NestJS provides a robust set of features for building modern web applications, including dependency injection, modularization, and a powerful CLI.
While working with NestJS, you might encounter the error message: Error: Cannot find module '@nestjs/terminus'
. This error typically appears when trying to use the Terminus module, which is part of NestJS's ecosystem for health checks and monitoring.
When you attempt to run your NestJS application, it fails to start, and the console logs display the error message indicating that the module @nestjs/terminus
cannot be found.
The error Cannot find module '@nestjs/terminus'
occurs because the Terminus package, which provides health check capabilities, is not installed in your project. This module is essential for implementing health checks in NestJS applications, allowing you to monitor the health of your services.
This issue arises when the @nestjs/terminus
package is either not installed or has been removed from your node_modules
directory. It could also occur if the package is not listed in your package.json
dependencies.
To resolve this issue, you need to ensure that the @nestjs/terminus
package is correctly installed in your project. Follow these steps:
Open your terminal and navigate to the root directory of your NestJS project. Run the following command to install the @nestjs/terminus
package:
npm install @nestjs/terminus
This command will add the package to your node_modules
directory and update your package.json
file.
After installation, verify that the package is listed under the dependencies in your package.json
file. It should look something like this:
"dependencies": {
"@nestjs/terminus": "^x.x.x",
...
}
Replace ^x.x.x
with the actual version number installed.
Once installed, you can import and use the Terminus module in your NestJS application. For example, in your module file, you can add:
import { TerminusModule } from '@nestjs/terminus';
@Module({
imports: [TerminusModule],
})
export class AppModule {}
For more information on using the Terminus module in NestJS, you can refer to the official NestJS Terminus documentation. Additionally, you can explore the GitHub repository for more examples and use cases.
(Perfect for DevOps & SREs)
(Perfect for DevOps & SREs)