Questions tagged [module-export]

33 questions
17
votes
2 answers

Building a JavaScript library, why use an IIFE this way?

I have noticed a lot of libraries use this style below to define their library. I also notice that the first self invoking function has something to do with Require.js or AMD systems, they always have factory as an argument, I will look more into…
Michael Joseph Aubry
  • 12,282
  • 16
  • 70
  • 135
10
votes
1 answer

When can a CommonJS named export be imported by an ES module?

I have an ES module that uses a named export from a CommonJS module that I authored. es.mjs import { MyNamedExport } from './commonjs.cjs'; console.log(MyNamedExport); commonjs.cjs (good one) exports.MyNamedExport = 'OK'; When I run the ES module…
GOTO 0
  • 42,323
  • 22
  • 125
  • 158
3
votes
0 answers

Unsatisfied version 0 from shell of shared singleton module firebase/messaging (required ^9.17.1) at getStrictSingletonVersion

Basically i want to add Firebase on my Angular app. I am using NX Module Federation and after i do npm i firebase i get the error above. I have one package.json for all microservices and shell together so there can't be version mismatch, i…
3
votes
1 answer

Tailwind CSS: Referencing to custom color in tailwind.config.js

In order to streamline my theming I'd like to reference to a custom color I defined and then pass it through a function to get a lighter or darker variant. I extend the default color theme using the following (partial) code: module.exports = { …
3
votes
1 answer

Why can't export variable members in a PowerShell module using VariablesToExport?

From How to Write a PowerShell Module Manifest I learned that I can export all the variables in the module using VariablesToExport = '*'. However, after using it, I found that I could not export any variables. After writing tests to confirm and…
Andy
  • 1,077
  • 1
  • 8
  • 20
2
votes
0 answers

export 2 plugins from next.config.js - withImages and environment variables

in next.js (next.config.js) I am trying to export 2 plugins: withImages and the current environment, I tried the following but it doesn't work, the env variable get as undefined const withImages = require('next-images') const withPlugins =…
Yuval Levy
  • 2,397
  • 10
  • 44
  • 73
2
votes
1 answer

Node.js module.exports a function with input

I have a little encryption file that adds a encrypted random number after some inputs: const crypto = require("crypto"); module.exports = function (x, y) { crypto.randomBytes(5, async function(err, data) { var addition = await…
Chen
  • 860
  • 10
  • 32
1
vote
1 answer

Express is not handling errors for function

I'm using a function for multiple times by calling from different routes. It's running but express/node.js not handling errors in the function. Here's the example. # routes.js var app = express() var { test } =…
Taner Tunçer
  • 89
  • 1
  • 8
1
vote
0 answers

How to handle module exports function return values

I had been coding a webapp and in his backend there's a function to create users. I need to use the values that are returned by that function, but how can I handle those values? The function code: module.exports = function(username, socialname,…
Igor Duca
  • 23
  • 3
1
vote
1 answer

ES6 typescript import all exported constants as an array

I'm trying to export many constants that I can later import and map through as an array. I can't put them all in one object and export them, because I'm using generics (OptionInterface) and I wish to keep the type validations. Currently, I export…
Shakedk
  • 420
  • 6
  • 15
1
vote
0 answers

Declare multiple module.exports in Node.js, TypeError: Router.use() requires a middleware function but got a Object

I'm developing javascript application and I have some problems. I want to export two routers, here is my code: const {Router} = require('express') const car = require('./car') const user = require('./user') // Routing const routerCar = new…
Matthew
  • 37
  • 5
1
vote
2 answers

TypeError: loginScreen.visibleOfWelcome is not a function

I want to access method defined in the javascript class. While running the code, I am getting error as TypeError: loginScreen.visibleOfWelcome is not a function This is my code : firstPage.CCC.js module.exports = class LoginScreen { get…
Neerajkumar
  • 300
  • 4
  • 19
0
votes
0 answers

webpack build successful but when start it return webpack config on terminal and close with ValidationError: Invalid configuration object

using webpack to build and run the vanilla javascript project which have node js and express js, webpack build working fine but running after making some changes in webpack.config.js file, it stopped working although build command run…
xkeshav
  • 53,360
  • 44
  • 177
  • 245
0
votes
1 answer

Exception has occurred: ModuleNotFoundError No module named 'src'

I am facing this problem while my "from src.simulation.simulator import Simulator" is in the same directory. what should i do now to resolve this problem? I have tried to solve this problem but did not understand what to do!!
0
votes
1 answer

Is there any way to specify the target resolution for a specific dependency in webpack?

Lets suppose our dependency has the following package.json described as: { "name": "some-dependency", "exports": { ".": { "browser": { "import": "...", "require": "..." }, "node": { "import": "...", …
MindLerp
  • 378
  • 1
  • 3
  • 15
1
2 3