简体   繁体   中英

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

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 class-transformer@0.3.1

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

Best regards and stay safe,
José Ignacio

For anyone using webpack with nestjs add the class-transformer/storage into the lazyImport on the webpack.config.js file.

The above issue is already opened in Github. changing the import statement to

import { defaultMetadataStorage } from 'class-transformer/cjs/storage';

Please try this it worked for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM