question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

question: not working across node.js modules

See original GitHub issue

We have a project with multiple node.js modules. Several of them use class-validator – but they don’t work together. Each module gets its own instance of the class-validator where the decorators are stored, so they can’t share common class validation. I’ve tried the useContainer method, but that doesn’t resolve the issue.

We need some sort of solution to make all the class-validator module instances work together.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:10
  • Comments:32 (20 by maintainers)

github_iconTop GitHub Comments

9reactions
MichalLytekcommented, Mar 19, 2018

@NoNameProvided flattening is a workaround, not the solution. What if you have a separate module that store the shared (between frontend and backend) code, like DTOs with class-validator decorators?

3reactions
MichalLytekcommented, Mar 19, 2018

Nope. When you require the class, it uses local node_modules, so during development with npm link you will have this problems with class-validator. Been there, done that 😉 I’ve used container with weird initialization (order of require) to make it work but global metadata storage would solve all the issues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - NodeJS some modules not working
NodeJS some modules not working · Yes the same way, The path is correct beacause it's in the same directory (rooms.js and fiveSocket....
Read more >
Have a JavaScript Module Not Found Error? Have you ...
If you're seeing a "module not found: error: can't resolve," in your Javascript code, here's an explanation as to why and how to...
Read more >
15 Common Error Codes in Node.js and How to Fix Them
Therefore, we've compiled this list of 15 common Node.js errors along ... The fix for this problem is to ensure that the target...
Read more >
Node.js v19.3.0 Documentation
Indicates the failure of an assertion. All errors thrown by the node:assert module will be instances of the AssertionError class. new assert.AssertionError( ...
Read more >
6 reasons your Node.js apps are failing
Problems occurring in Node.js application deployments can have a range of ... The superstack and trace modules allow you to obtain exception traces...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found