commonjs Questions
3
Is it possible to use react-select directly from the browser without
bundlers nowadays?
The most recent version that I found to be able to do so was 2.1.2:
How to import from React-Select CDN with ...
Psalter asked 10/7, 2020 at 21:29
6
Solved
I'd like to use Typescript for my Google Apps Script (GAS) projects, but I can't find a way to compile my code into something that GAS accepts.
GAS doesn't support export, and Typescript seems to...
Scriptorium asked 14/2, 2018 at 16:26
1
I got this warning, but I dont understand why 'localforage' depends on CommonJS. I had googled for few days, but I can't find any solution that fit with my problems.
WARNING
C:\xxx\node_modules\@...
Cystectomy asked 1/11, 2022 at 14:40
2
I need to develop a nodejs application in which it should be possible to dynamically import ESM modules in a commonJS module during the run time.
Without requiring the need to specify "type&q...
Cimbalom asked 2/6, 2023 at 7:38
2
Solved
I am trying to load a single ESM module in my TypeScript CJS project. All examples I find are for JavaScript.
// example.ts
export const example = async () => {
const module = await import(&quo...
Barone asked 8/5, 2024 at 9:45
5
Solved
Question:
How to import JavaScript files in NodeJS using file paths from project root? (instead of relative file paths)
In other words, my team is trying to transition from Syntax Style A to Syntax...
Pneumograph asked 21/3, 2023 at 20:44
46
Solved
I've started using webpack2 (to be precise, v2.3.2) and after re-creating my config I keep running into an issue I can't seem to solve I get (sorry in advance for ugly dump):
ERROR in ./src/main.j...
Ornstead asked 27/3, 2017 at 3:40
7
I am working in NodeJS. I have a great deal of legacy code including several packages that are used in many places. This code is all CommonJS, Node require() module structures.
Node now supports ES...
Dracaena asked 24/4, 2021 at 18:38
1
I have a Node.js project whose modules are imported in the Common.JS way using require. However, the need arose to import a package that is ESM only.
One way to use ESM import from in my project wa...
Hulbert asked 19/7, 2022 at 22:59
1
`#11 44.55 ERROR require() of ES Module /app/node_modules/string-width/index.js from /app/node_modules/wide-align/align.js not supported.
#11 44.55 Instead change the require of index.js in /app/n...
Quinn asked 14/2, 2024 at 4:57
2
Solved
Is there any performance advantage or disadvantage of using ES modules over CommonJS modules in a nodejs backend project? I'm asking this because I see a lot of people using CJS still even though n...
Orthopedist asked 7/4, 2022 at 10:39
4
Solved
Calling setTimeout with setImmediate has unpredicted behaviour if using CommonJS modules. But if you switch to ESM ("type": "module" in package.json), it will always execute set...
Maharajah asked 30/12, 2023 at 18:18
3
Solved
I am stuck on a tutorial which is incorporating Tailwind, which in this case is tailwind 3.3.2.
Per the tutorial, I am supposed to open a file called tailwind.config.js and paste the below code fro...
Siloam asked 28/6, 2023 at 3:37
3
Solved
I have a number of JavaScript "classes" each implemented in its own JavaScript file. For development those files are loaded individually, and for production they are concatenated, but in both cases...
Vulgarism asked 2/2, 2011 at 0:23
1
Trying to migrate some old TypeScript code from CRA to Vite, and getting stuck on a problem with Vitest. The project has dependencies like this:
my-project (ESM)
depends on: lib1 (CJS)
depends on...
2
Solved
I have a create-react-app project I'm migrating to Vite. That project uses "styled-components" like this:
import styled from 'styled-components';
const someDiv = styled.div`...`;
Now th...
Kingship asked 23/12, 2022 at 10:36
2
I am trying to get the Leaflet library to play well with my Typescript project.
My project follows the commonJs pattern (imports\exports in my source files), but when I build with webpack, the com...
Woermer asked 24/2, 2018 at 8:40
24
Solved
I have a script I am requiring from a Node.js script, which I want to keep JavaScript engine independent.
For example, I want to do exports.x = y; only if it’s running under Node.js. How can I per...
Seventh asked 19/11, 2010 at 11:41
0
I am trying to build a react app with vitejs, the build is successful but when I try to serve it on browser I get this error
Uncaught ReferenceError: require is not defined
I have tried all the op...
Deputation asked 17/7, 2023 at 7:45
2
How do I tell Webpack that it should treat my loader as an ES Module and not CommonJS?
My goal is to write a Loader that uses the ES Module syntax (export default...)
Demo (not working): https://st...
Magistrate asked 24/8, 2022 at 13:24
4
Solved
I have a decent size project and I need to do a little restructuring.
I am using mongoose as my ORM for node. I would like to put all my mongoose models in a folder called 'models'. I have read th...
1
Let's imagine we have a file containing next JS code:
process.nextTick(()=>{
console.log('nextTick')
})
queueMicrotask(()=>{
console.log('queueMicrotask')
})
console.log('console.log')
a...
Trescott asked 29/12, 2021 at 11:47
2
Developing JavaScript in VSCode, I see this error on line const Koa = require("Koa");:
File is a CommonJS module; it may be converted to an ES6 module. ts(80001)
and after I searched, I...
Uttermost asked 17/6, 2019 at 8:57
2
I have an express server written in typescript with "module": "es2020" in its tsconfig.
I've also developed another es2020 module for my graphql API, still in typescript, and th...
Dailey asked 6/1, 2022 at 9:55
7
So, I'm attempting to do something which on the surface should be very simple...
I have some constants defined in:
//constants.js
module.exports = {
MY_CONSTANT: "TEST"
}
I have a file...
Bobsleigh asked 13/3, 2019 at 8:27
1 Next >
© 2022 - 2025 — McMap. All rights reserved.