Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Filter by
Sorted by
Tagged with
0 votes
0 answers
84 views

Create website that uses ES modules yet can be saved locally

Is it possible to create a single-page website hosted on static hosting (no custom headers etc.) that uses ES modules in external .js files and still can be saved as "Website, complete" in ...
mihi's user avatar
  • 6,761
0 votes
0 answers
14 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 ...
Vitaliy Oliynyk's user avatar
0 votes
0 answers
95 views

How do I configure package.json "exports" for both TypeScript and TSX files?

I have been using a new package.json entry points using exports. TypeScript works very well without any problems. So far, I have used it in a monorepo for a backend application where all files are .ts ...
Harshal Patil's user avatar
1 vote
0 answers
29 views

Did Chrome change their content security policies for importing scripts?

We are dynamically importing modules from esm.sh. This works well with esm.sh being added to the list of domains for the script-src CSP. Since Chrome has updated to version 140++ the imports throw an ...
Dennis Bauszus's user avatar
-2 votes
2 answers
87 views

Uncaught ReferenceError: require is not defined, in my Vercel app

Problem I have a React app using Leaflet.js (v.1.9.0) and I host it in Vercel. Building works OK, but when visiting my app online logs this message in console: Uncaught ReferenceError: require is not ...
LoukasPap's user avatar
  • 1,348
0 votes
1 answer
61 views

Check valid import with ESM

Using TypeScript and ESM ("type": "module" in package.json), when I import from lodash: import { uniq } from 'lodash' I get the following error: SyntaxError: Named export 'uniq' ...
Magnus Jeffs Tovslid's user avatar
3 votes
0 answers
71 views

Jest with TypeScript weird import error: SyntaxError: Cannot use import statement outside a module

Im trying to configure an unit test for my website with Jest and I can't get it to work correctly. I've tried some of the solutions suggested by the ts-jest documentation but it still hasn't worked. ...
Samuel Augusto's user avatar
0 votes
0 answers
49 views

Failing to export React (the library itself) as a esm module using Rollup

I am building a frontend with no buildstep using buildless react. I previously loaded react from a cdn similar to this: import React from "https://esm.sh/react" But I prefer to install ...
Stuurpiek's user avatar
0 votes
1 answer
56 views

How to use import inside service worker

I'm getting the error message below for my service worker which starts with import statements. The registation of the service worker is as a module, so it should work as far as I know? Service Worker ...
Simon Ferndriger's user avatar
-2 votes
1 answer
46 views

How do I break down my code into smaller and manageable chunks of modules? [closed]

I am learning JavaScript and I currently I am learning about modules. I have no idea how to do it. I do know that I have to use export and import to do it but I don't know how I should proceed with it ...
User's user avatar
  • 9
1 vote
1 answer
92 views

p-limit - Javascript modules ES6

On a webpage, I am not using Node.js. I wanted to use p-limit like this: <script src=" https://cdn.jsdelivr.net/npm/[email protected]/index.min.js "></script> But this doesn't work. ...
Flo's user avatar
  • 485
0 votes
2 answers
823 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 ...
Arvind Kumar Sharma's user avatar
-3 votes
1 answer
79 views

Is this object created only once or every time I import it? [duplicate]

Since I'm having a bug that I can't figure out, a cold doubt has assailed me:. I have the below code in a Svelte 5 SvelteKit app. And I'm importing import { queryClient } from './src/query.ts from ...
Fred Hors's user avatar
  • 4,273
0 votes
0 answers
22 views

How to use the same configuration file in both content scripts and background module in Manifest V3? [duplicate]

I’m developing a Chrome extension using Manifest V3. My background script is a module ("type": "module"), so it uses import { CONFIG } from './config.js';. My content scripts, ...
João Ferreira's user avatar
0 votes
1 answer
30 views

Convert "browser" fields in package.json to esm "exports"

I have a package that uses fields like this to hide the inclusion of node.js fs fields from the browser { "name": "mypackage", "version": "1.0.0", "...
Colin D's user avatar
  • 3,189
2 votes
1 answer
103 views

Why are export conflicts silently removed in ES6 modules? [closed]

Let's suppose we have 3 files // a.mjs export * from "./b.mjs"; export * from "./c.mjs"; // b.mjs export const foo = 1; export const bar = 2; // c.mjs export const bar = 3; Both ...
AFatNiBBa's user avatar
  • 167
2 votes
0 answers
30 views

Unable to import `sugar-date` into ESM project

I wanted to use Sugar's Date module for some NLP parsing and so I installed sugar-date only because I only need the date: yarn install sugar-date But I got the error: error TS2306: File 'node_modules/....
Rusty's user avatar
  • 356
0 votes
0 answers
58 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/, }, ], ...
AnuRS's user avatar
  • 1
1 vote
2 answers
87 views

Webpack automatically resolve default import

I am attempting to migrate our single-page application from RequireJS to Webpack. As part of this transition, I am gradually rewriting our hundreds of modules from ASM define() syntax to modern ESM ...
John Brink's user avatar
-2 votes
1 answer
63 views

How can I use 'stats-base-dists-chisquare' in SVG using JavaScript?

In SVG file, I written some JavaScript code to calculate chisquare.cdf values. After searching a lot, I find following code that seems to be for me: <?xml version="1.0" encoding="UTF-...
schlebe's user avatar
  • 3,839
0 votes
0 answers
30 views

unbuild cjs output behave differently from normal & stub mode

Here is the demo project: https://github.com/Renderz/unbuild-test when I run npm run build then npm run test-cjs , the output shows { a: 1 } when I run npm run stub then npm run test-cjs, the output ...
yifeng jiang's user avatar
2 votes
1 answer
197 views

Cannot Find Module Error When Running ts-node with Relative Path

I have tried several different things to try to fix this issue but no matter what I do when running npx ts-node updateCostCenters.ts I continuely get this error Error: Cannot find module '@/../prisma/...
codernoob8's user avatar
1 vote
1 answer
144 views

Cannot import @apollo/client in Vinxi/Vite/Tanstack Start

The following line works fine in the browser and in Bun: import { ApolloProvider } from "@apollo/client"; but when I run it in SSR (inside Tanstack Start / Vite / Vinxi) I get an error ...
Michael Lorton's user avatar
2 votes
2 answers
284 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 ...
Ole's user avatar
  • 48.2k
0 votes
1 answer
83 views

Creating npm packages for both CJS and ESM using the exports property

The library mode documentation for Vite has an example of a package.json that uses require for UMD modules and import for ESM and this is the example: { "name": "my-lib", "...
Ole's user avatar
  • 48.2k
0 votes
0 answers
20 views

Is there a performance advantage to pre-including an imported module via <script> tag?

Suppose I have a single module, app.mjs. I include it for use in a browser: <script src="app.mjs" type="module"></script> app.mjs imports another module, utils.mjs: ...
Richard Simões's user avatar
0 votes
0 answers
30 views

Working on ArcGIS SDK for JS version 4.32.9 using React facing issue import{_ as o}from"../chunks/ While importing Map

Working on ArcGIS SDK for JS version 4.32.9 using React, facing issue import{_ as o}from"../chunks/ while importing Map ERROR in ./node_modules/@arcgis/core/views/MapView.js (./node_modules/css-...
Sagar Chougule's user avatar
-1 votes
1 answer
42 views

How can I access the ${orderId} and ${payment} which is present in the method chaining of the promise to my last block of promise? [duplicate]

const cart = ["shoes","shirts","boxers","pants"] function creatOrder(cart){ return new Promise((resolve,reject)=>{ if(!ValidateCart(cart)){ ...
Grimmj0w's user avatar
0 votes
1 answer
101 views

Are these export syntax the same [duplicate]

I see a lot of people start a component like: export default function Example(){XYZ} Is that the same as writing the function and then exporting at the bottom of the page like so? function Example(){...
Aleks3000's user avatar
0 votes
1 answer
108 views

ExperimentalWarning: CommonJS module /app/noop.js is loading ES Module /app/...js using require()

Underneath it also says Support for loading ES Module in require() is an experimental feature and might change at any time
ButteryAvocado's user avatar
0 votes
0 answers
109 views

Graphql-codegen broken with Node v23

When trying to generate graphql queries automatically for my vite app, I'm encountering this error: 18:02 $ npm run codegen > [email protected] codegen > graphql-codegen /home/...
rmartrenado's user avatar
  • 1,616
0 votes
0 answers
55 views

dynamic esmodule import in vuejs

I got a vueJS app where people can use widgets. Widgets are composed of 2 VueJS components and an index.ts where the index.ts export default object like : {name: "Foo", component: ...
LeopoldBriand's user avatar
2 votes
2 answers
116 views

Alternative to 'assert' in Node JS with strict mode

I have a Firebase Functions project that has "type" set to "module" in package.json so that I can use ES6 syntax. Some of the files import data from another json file with a line ...
Matthew Michaud's user avatar
0 votes
1 answer
1k views

plugin externalize-deps - This package is ESM only but it was tried to load by `require`

I am installing a plugin in Vite, but I run into an error message stating that the package only supports ESM, not CJS. package.json { "devDependencies": { "example-package": &...
rozsazoltan's user avatar
  • 18.1k
0 votes
0 answers
10 views

How to use module imports in my main content script [duplicate]

I'm building a Chrome extension and getting this error when trying to use ES6 modules in my content script: Uncaught SyntaxError: Cannot use import statement outside a module Here's my current setup: ...
Izaan's user avatar
  • 145
0 votes
0 answers
453 views

Vite Library Mode with CSS Imports

I've rebuilt my small React crossword library to use Vite. It seems to work fine in dev but when I publish the package and import it to another project I get the following error: [vite] Error when ...
tomblackwell's user avatar
0 votes
1 answer
182 views

Uncaught SyntaxError: The requested module does not provide an export named 'Redis' in ioredis

I am using ioredis in my Node.js + Express project with ES modules ("type": "module" in package.json). When I try to import Redis like this: import {Redis} from "ioredis";...
Rakesh Nagarkar's user avatar
0 votes
0 answers
39 views

NextJS Server Action cannot read data from exported list

I have a NextJS Project that uses instrumentations.ts to create a websocket server. I am trying to access the connected clients from a server action however, any exported variables are defaulted to ...
Ethan's user avatar
  • 1
0 votes
0 answers
15 views

How do I fix "Cannot use import statement outside a module" in my Chrome Extension content script? [duplicate]

I'm developing a Chrome extension (Manifest V3) and using ES6 modules in my content script (content.js). My code starts with: However, when the extension loads on https://nkiri.com/, I get the ...
3rippleflex 's user avatar
0 votes
2 answers
620 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 ...
haoyu wang's user avatar
-1 votes
1 answer
174 views

Error [ERR_MODULE_NOT_FOUND]: Cannot find module occurs when invoking a serverless lambda function locally while functioning well on remote aws

To improve the project's functionality and overall performance. As part of this effort, we updated our SLS "handler.js" file to use ES modules and renamed it to "handler.mjs". The ...
Abdullah's user avatar
0 votes
0 answers
214 views

importing vidstack as module from CDN

I am adding player functionality to a HTML page using vidstack.io from CDN. I would like to do it in a clean fashion (admittedly, I have not been to the JS land for a long time). I understand modules ...
eudoxos's user avatar
  • 19.2k
3 votes
0 answers
146 views

Protocol http is not support by the default ESM loader

My goal is to import components from website A in website B using vite-plugin-federation so I can use the same components in both websites. For technical details: Both websites use the Qwik framework ...
Justin Slijkhuis's user avatar
0 votes
1 answer
173 views

bundling of a dependency-of-dependency in commonJS format fails - converted to ESM

I am working on a React project in ESS6 module style; using vite for bundling. We want to include some modules we haven written ourselves as dependencies. These in turn depend on third party-modules ...
DavidP's user avatar
  • 117
0 votes
1 answer
63 views

'this' is Undefined in Instance Methods when Importing Puppeteer Inside a Module

I am running into an issue with Puppeteer where 'this' is undefined within the Puppeteer class instance methods when Puppeteer is imported into a module. When I import Puppeteer directly in my main ...
FusedKush's user avatar
0 votes
1 answer
63 views

tsx (typescript-execute) imports index.js instead of index.d.ts

I'm trying to set up tsx (typescript-execute) in my project, my package.json is as follows: { "name": "bb-tcg-backend", "version": "1.0.0", "...
Fullaccess 's user avatar
2 votes
0 answers
429 views

Building VS Code extension with ES modules by coding the extension activator as CommonJS

This is my first VS Code extension and first code written in TypeScript. While I know support of ES Module extensions is still unsupported, I decided to try creating the extension loader as a CommonJS ...
sthames42's user avatar
  • 1,038
0 votes
0 answers
21 views

Compiling typescript into ECMAScript Modules for google firebase functions

I am developing a react app with a google firebase backend. Additionally, I have some shared logic between the frontend and the backend that I store in a shared library. These are all written in ...
Someone's user avatar
  • 882
0 votes
0 answers
49 views

Azure DevOps extension: Use packaged node_modules instead of global node modules

I am developing a custom pipeline task for Azure DevOps to extend commit lint's functionality. All source files (and node modules) have been packaged inside the .vsix file. However when running the ...
Martin C's user avatar
0 votes
1 answer
900 views

AWS Lambda Nodejs 20.x fails with init Status: error Error Type: Runtime.Unknown

I have upgraded a previously working lambda function from node v18 to node v20. After going through the various issues that nodejs 20 introduced (a bunch of seemingly breaking changes), I finally got ...
Michael Coxon's user avatar

1
2 3 4 5
58