Search code examples
angularnestjsserver-side-renderingangular-universal

Module not found: Error: Can't resolve 'class-transformer/storage' - Angular Universal / NestJs


Folks, I've been trying to implement an application using angular with angular universal and NestJs. I believe that is possible to seize the nest server not only for SSR, but also to also provide API endpoints.

I've made the setup recommended on https://github.com/nestjs/ng-universal using ng add @nestjs/ng-universal, pretty standard. After that I added my code to the angular src folder and installed the needed dependencies.

The problem is that when I try to import a module to nest app.module, I get the following error: Error: Module not found: Error: Can't resolve 'class-transformer/storage'

I've tried to use webpack, but since my knowledge on webpack is petty, the results were failure after failure, as expected.

First, is it possible to seize the server also to provide endpoints? Second, what should I do to resolve this module?

Please find below the repository for reproducing the issue:

https://github.com/vitordhers/universal-nest

Thanks in advance


Solution

  • Just faced the exact problem, and when I saw your post my glance of hope just disappeared after I saw the date and zero answers :P
    Anyway, ended up here https://github.com/typestack/class-transformer/issues/563 to finally downgrading the class-transformer package to 0.3.1 Worked for me and I hope it does for you too:

    npm install --save [email protected]
    

    Couldn't make nestjs/ng-universal work though, but that's for another question.

    Best regards and stay safe,
    José Ignacio