1,347 questions
-2 votes
1 answer
66 views
ESM & CommonJS Dual Support in an Existing Node.js Project [duplicate]
I'm updating a Node.js project to support both CommonJS and ES Modules (Dual Package). My current issue appears when trying to load the module from the project root using exports field instead of main....
0 votes
0 answers
21 views
Using ESM plugins in ESLint CommonJS config
So I have an Angular NX Monorepo, which has a base eslint.config.js, and each lib extends the base config in its own config. All configs are CommonJS and use require() syntax. I want to use the simple ...
1 vote
0 answers
116 views
transformMixedEsModules not working for mixed ESM/CommonJS modules
I'm having some confusion when using the rollup plugin commonjs. In my application, some third-party packages in node_modules use CommonJS syntax. By default, I use @rollup/plugin-commonjs to handle ...
1 vote
1 answer
33 views
How do I retain types of namespace over dynamic loading?
I'm building a cross-platform app in Node.js + TypeScript that uses OpenCV. On Windows I use the original opencv4nodejs, and on Linux I use the actively maintained fork @u4/opencv4nodejs. To avoid ...
0 votes
0 answers
77 views
Vite/Nuxt 3 dev server: "eventemitter3 doesn't provide an export named 'EventEmitter'" but works in production build
i'm building a Nuxt 3 (Vue 3) app using Vite as the dev server. My app uses dependencies like @solana/web3.js and socket.io-client, which internally depend on eventemitter3. when I run the dev server (...
0 votes
2 answers
982 views
Importing commonjs module in a Vite project
I'm working on a Vite-powered frontend project that needs to use code from a shared common folder located one level up in the directory structure. I converted this common folder into a CommonJS module ...
0 votes
2 answers
197 views
"name" is not exported by "module" even when using @rollup/plugin-commonjs in vite (rollup) build
I'm migrating a react site from from CRA (webpack) to Vite (Rollup), and despite using the @rollup/plugin-commonjs addin in my vite config, (which did solve all of the name-is-not-exported-by-module ...
0 votes
1 answer
209 views
Deploy Express server to Vercel with ESM dependency?
I have an Express server which uses a ESM dependency react-pdf. I also need the file to be .tsx as I'm using TypeScript JSX for rendering. I have this working locally but I run into issues when trying ...
-1 votes
2 answers
217 views
Seeing Node.js-related warning for module word in jquery.min.js
When starting server for my Hanami 2.2 web app, I am seeing following JS-related warnings: 20:21:42 assets.1 | [my_app] ▲ [WARNING] The CommonJS "module" variable is treated as a global ...
0 votes
0 answers
62 views
Support ESM in CommonJS application context
Here are key fields from webpack and ts configs: webpack: module: { rules: [ { test: /\.ts$/, use: "ts-loader", exclude: /node_modules/, }, ], ...
0 votes
1 answer
216 views
How to import functions from CommonJS files when using Vite for React development
I have a Vite project set up with React and JavaScript. One of the packages I need doesn't use ESM, so I'm using require in a .cjs file, creating a function and exporting it to use in the React App....
0 votes
0 answers
143 views
Vite / React - Package imports a file without a default export (UMD vs ES6). Can I force a default export through vite configuration?
I am working on a Vite / React application which has a pretty typical setup. I now need to integrate with an older package and I'm running into some issues. The package has code like this in a js file:...
0 votes
0 answers
33 views
NodeJS - CommonJS and ESModule compatible current file
In a single TypeScript file, how can I get the path to the current file's directory in such a way that is compatible with both CommonJS and ESModules? In CommonJS, the following works: const dir = ...
2 votes
2 answers
309 views
Can we import from CommonJS modules in Node now using ESM import syntax?
Can we import from CommonJS modules in Node now using ESM import syntax? So if commonjsmodule is a cjs module that exports like this: exports.add = function() {...} Can we import from it like this ...
1 vote
0 answers
130 views
Make "require" work like any function with TypeScript type inference
Context In a JavaScript file, let require be a variable (whether top-level or local, in a function, etc.), that does not work like the CommonJS one: function () { ... /** * @param {...