2,887 questions
0
votes
0
answers
86
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 ...
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 ...
-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 ...
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. ...
0
votes
1
answer
58
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 ...
1
vote
1
answer
93
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.
...
-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 ...
0
votes
1
answer
32
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",
"...
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/....
1
vote
2
answers
88
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 ...
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 ...
1
vote
1
answer
145
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 ...
0
votes
1
answer
84
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",
"...
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-...
0
votes
1
answer
102
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(){...
0
votes
0
answers
110
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/...
2
votes
2
answers
118
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 ...
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:
...
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";...
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 ...
-1
votes
1
answer
175
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 ...
3
votes
0
answers
149
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 ...
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 ...
2
votes
0
answers
439
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 ...
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 ...