Any import will get the following TypeScript error: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'.
If I don't specify any export (just import OBSWebSocket from "obs-websocket-js";), an additional TypeError is thrown at runtime: OBSWebSocket is not a constructor. Manually specifying /json or /msgpack gets rid of this. The other error remains.
Description:
Package resolution is broken in a TypeScript project using CommonJS with Module and ModuleResolution set to
Node16
. Also see: https://arethetypeswrong.github.io/?p=obs-websocket-js%405.0.5 => node16 (from CJS). This breaks importing completely.Any import will get the following TypeScript error:
The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'.
If I don't specify any export (just
import OBSWebSocket from "obs-websocket-js";
), an additional TypeError is thrown at runtime:OBSWebSocket is not a constructor
. Manually specifying/json
or/msgpack
gets rid of this. The other error remains.Versions Used (if applicable):