Skip to main content

All Questions

-1 votes
1 answer
34 views

Using "type": "module" in package.json breaks javascript default parameters

I have a package.json file that contains the line "type": "module",. This line triggers errors when running node a_script.js. Its as if the default parameter functionality of ...
erikejan's user avatar
1 vote
1 answer
49 views

How to find where promise was created?

I posted this question a couple of days ago, then removed it after I was pointed that it essentially didn't demonstrate the problem I was dealing with. Then I was asked to restore the question, but I ...
d.k's user avatar
  • 4,406
0 votes
1 answer
71 views

Webpack's ambiguous relationship with ES6 modules [closed]

Does Webpack support ES6 modules natively or not? This is a simple question but its answer seems to be more complicated than I initially thought. On one hand, Webpack allows you to use ES6 syntax ...
e18r's user avatar
  • 7,973
0 votes
0 answers
33 views

Uncaught ReferenceError: Cannot access 'sprocket' before initialization

I am currently working on an app and have run into the following error, Uncaught ReferenceError: Cannot access 'sprocket' before initialization This example below demonstrates the layering I ...
user1790300's user avatar
  • 1,785
1 vote
0 answers
29 views

Main function with ES Modues in JavaScript [duplicate]

In NodeJS we can follow the convention of having a main method, and we can ensure the main method is only executed if the module was ran by the user, and not accessed from an import as follows: ...
Andrew S's user avatar
  • 2,947
0 votes
1 answer
53 views

Router cannot be exported when using es6 syntax

I am trying to rewrite NodeJS modules(constant xxx = require('yyy')) into es6 format. I tried to export the router using export syntax in es6 but the following error always popped up: throw new ...
doraemon's user avatar
  • 786
0 votes
1 answer
14 views

error in the operation of the -dev flag NPM

Can you tell me why when you use the syntax npm i <package-name> --save - dev The dependency is added to the list of common dependencies. But if you don't use abbreviations, everything works as ...
Arsenii's user avatar
3 votes
2 answers
262 views

NodeJS import module not found when leaving off .js file extension and when importing implied root index.js from directory

What does it mean if an import cannot find the module but the file path and case sensitivity is correct? I'm sensing a NodeJS issue or config issue (babel? eslint?) rather than the JS itself. I've ...
Mia Ciasullo's user avatar
0 votes
0 answers
71 views

Unable to use Javascript Library in Browser

I want to log all the events from a midi file. I found a library that should do just that: text Problem is I can't figure out how to use it in a website. I've tried with a CDN from jsdeliver, however ...
user14101905's user avatar
0 votes
2 answers
107 views

Run CommonJS code in ESM Module using runInThisContext

A third party dependency returns a javascript code which I would like to execute using vm.runInThisContext. Unfortunately the javascript module systems missmatch as my script has to be ...
jantimon's user avatar
  • 37.7k
1 vote
1 answer
61 views

Promise.race() returning resolved promise instead of first rejected promise

When I run the following code, it Outputs 'Promise 1' even though the Promise that should settle first in the race is promise2 and should Output 'Error Promise 2'. What is the logic behind the output ...
thundrstorm's user avatar
0 votes
0 answers
204 views

Uncaught SyntaxError: The requested module '/node_modules/classnames/index.js?v=caf6ac94' does not provide an export named 'default'

Using this design system https://react.lightningdesignsystem.com/ in a react app built with vite. When I try using the es6 modules import statement import BrandBand from '@salesforce/design-system-...
user9578192's user avatar
1 vote
0 answers
24 views

I want to clear the local storage when user close the window but if it reload the window then do nothing

I want to clear the local storage when user close the window but if it reload the window then do nothing I use this but it will cler the local storage when I reload the page. I use this function ...
Faisal Ur Rehman's user avatar
0 votes
0 answers
50 views

Need help understanding promise architecture in nodejs

I have the following code that is used to create a bunch of separate consumers for separate topics. Once these consumers are created, i iterate through every single one of them and try to read message....
Akash's user avatar
  • 405
0 votes
0 answers
26 views

NodeJS parseFloat approximation [duplicate]

Why does the following happen in NodeJS. NodeJS version 14.15.0. > Number.parseFloat("37.12") 37.12 > Number.parseFloat("37.12")*100 3711.9999999999995 I was expecting the ...
Shibasis Sengupta's user avatar

15 30 50 per page
1
2 3 4 5
161