81 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
0
votes
1
answer
97
views
How to import 'lightweight-charts' with ES module way?
I would like to use lightweight-charts library with ES module.
I would like to use lightweight-charts on browser so I followed instruction of the document
https://tradingview.github.io/lightweight-...
3
votes
1
answer
66
views
Why are namespaced import entries sorted alphabetically?
In NodeJS:
// module.js
export const b = 1
export const a = 2
// index.js
import * as ns from './module.js'
console.log(Object.keys(ns)) // [a, b]
I cannot find why it is not the same as the export ...
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 = ...
0
votes
0
answers
56
views
ReferenceError: exports is not defined in ES module scope while deploying
I am getting this error "ReferenceError: exports is not defined in ES module scope" while deploying my backend to render.com
I just have two typescript files which when compiled creates two ....
0
votes
2
answers
663
views
Node v20.11.1 mjs Addressing path error "is not supported resolving ES modules imported"
I want to figure out how the ESM module finds dependencies in nodejs.
For example, I have an test.mjs file
import value from 'test-a'
console.log(value)
'test-a' It is a nodeModule dependency ...
1
vote
0
answers
414
views
Vitest require ESM Error. How do I get past this
Im running React+Vite. And im trying to setup unit test cases for components, but when I try to run it, I'm getting the following error
Error: require() of ES module ...\index.js from
...\...
0
votes
1
answer
223
views
SyntaxError: Unexpected token 'export' in Jest
I am using Node v22.12.0 with Jest. I am trying to import a library that works find on my other typescript projects (with NestJS) and I get the following error.
SyntaxError: Unexpected token 'export'
...
2
votes
2
answers
80
views
Import `path` for Node reacts differently in NestJS
I have a NestJS application with some commands attached to it. When I run the application I can import path as
import path from 'path';
and it will work fine.
When I use nest-command to run a CLI ...
1
vote
1
answer
475
views
How to dynamic import chai in CommonJS?
chai latest version 5.1.2 move to ESModule. Is it possible continue use it in CommonJS file? chai is just a dev dependency in my project, used for unit test. I don't want to upgrade my modules to ...
-1
votes
1
answer
1k
views
How do I use both `require` and `import` in a Node.js script?
having a node js basic project setup with package.json , install a package and try to use both require and import statment in the same file; to do that here is what did so far but not working.
First ...
2
votes
0
answers
85
views
CommonJS vs. ES Modules: this Behavior with call(null) and call(undefined)
I saved the following code as index.cjs so that node considers it as a CommonJS module.
console.log(this);
function getThis() {
console.log("this", this);
}
getThis.call(null);
getThis....
0
votes
1
answer
152
views
Dynamic require of 'https' is not supported error while generating cypress cucumber report in v 10
✘ [ERROR] Could not resolve "https"
node_modules/@ng-apimock/cypress-plugin/dist/cypress.plugin.js:4:22:
4 │ const https = require("https");
╵ ~~~~~~~
...
0
votes
2
answers
979
views
How to properly mock import.meta.url in Jest with TypeScript and NodeNext module system?
I'm trying to mock the import.meta.url property in a Jest setup file within a TypeScript project using the NodeNext module system. My project is configured with "module": "NodeNext"...
1
vote
1
answer
819
views
Playwright - SyntaxError: Unexpected token 'export' - external npm package
I have created npm package in order to use it withing our organization. It containing some reusable code for testing. It is published to our internal feed and i have installed in destination project ...
1
vote
1
answer
109
views
How does EcmaScript handle recursive modules?
Recently I came across an eslint warning in my project about a circular dependency. I previously thought circular references are impossible in ES modules. But apparently they work in some situations.
...