Hello Stack Overflow community,
I'm working on a project using NestJS and AdminJS, and I've encountered an issue where TypeScript cannot find the module @adminjs/nestjs or its corresponding type declarations. This issue is preventing me from integrating AdminJS with my NestJS application.
"@adminjs/nestjs": "^6.1.0",
What i tried:
Installation: I first attempted to install the @adminjs/nestjs package using npm, ensuring that the package was correctly added to my project's package.json file. Importing and Usage: After installation, I imported the AdminModule from @adminjs/nestjs into my NestJS module and attempted to use it according to the documentation and examples provided. TypeScript Configuration: I reviewed my TypeScript configuration to ensure that it was set up to recognize the types from @adminjs/nestjs. This included checking my tsconfig.json file for any relevant settings that might affect module resolution. Searching for Solutions: I searched for similar issues on Stack Overflow, GitHub, and other developer forums. I also checked the official documentation and GitHub issues for @adminjs/nestjs to see if others had encountered and resolved the same problem. Environment Check: I verified that my development environment, including Node.js, NestJS, and TypeScript versions, were compatible with the @adminjs/nestjs package requirements.
The newest version of AdminJS is ESM only - meaning it is no longer compatible with a default NestJS application. https://docs.adminjs.co/installation/plugins/nest
You basically have 3 ways to go about this:
The way you go about it is by creating the following method
This allows you to import any ESM package from a CommonJS app without it being automatically converted to a 'require' call.
Then, in your Nest app main.ts:
In your module imports:
And just in case you were using the uploadComponent (example AWS config for image files):
SLIGHT EDIT: The above code for the upload functionality will not work. The interface for the AWS provider has been changed. You'll need to set it up like this: