node: getting error importing CommonJS module however I try to import it

Viewed 1126

I have a local node module, @em/inVis in my company whose index.d.ts file looks as follows:

import UWeb from "./UWeb";
import UWebParams from "./UWebParams";
export { UWeb, UWebParams };

elsewhere within the app, it's used as follows in typescript files

import { UWeb, UWebParams } from "@em/inVis";

when I try to do that in my TS file, I get the node error:

SyntaxError: Named export 'UWeb' not found. The requested module '@em/inVis' is a CommonJS module, which may not support all module.exports as named exports. CommonJS modules can always be imported via the default export, for example using:

import pkg from '@em/inVis'; const { UWeb, UWebParams } = pkg;

so when I try using that approach suggested above, I am getting the node error:

SyntaxError: Cannot use import statement outside a module not sure what I am doing wrong.

0 Answers
Related