Node.js · Senior · Question 51 of 75
What is the 'dual package hazard'?
- 1Two packages with the same name on npm
- 2A package that depends on itself
- ✓Correct answer: A package shipped as both CJS and ESM may be loaded twice in one app, creating two copies of its state and failing
instanceofchecks
Explanation
Solutions: ship ESM only now that require(esm) works, or keep state in one format and wrap it in the other.