You can do something like:

module.exports = {
    method: function() {},
    otherMethod: function() {},
};

Or just:

exports.method = function() {};
exports.otherMethod = function() {};

Then in the calling script:

const myModule = require('./myModule.js');
const method = myModule.method;
const otherMethod = myModule.otherMethod;
// OR:
const {method, otherMethod} = require('./myModule.js');
Answer from mash on Stack Overflow
Top answer
1 of 4
227

The export default {...} construction is just a shortcut for something like this:

const funcs = {
    foo() { console.log('foo') }, 
    bar() { console.log('bar') },
    baz() { foo(); bar() }
}

export default funcs

It must become obvious now that there are no foo, bar or baz functions in the module's scope. But there is an object named funcs (though in reality it has no name) that contains these functions as its properties and which will become the module's default export.

So, to fix your code, re-write it without using the shortcut and refer to foo and bar as properties of funcs:

const funcs = {
    foo() { console.log('foo') }, 
    bar() { console.log('bar') },
    baz() { funcs.foo(); funcs.bar() } // here is the fix
}

export default funcs

Another option is to use this keyword to refer to funcs object without having to declare it explicitly, as @pawel has pointed out.

Yet another option (and the one which I generally prefer) is to declare these functions in the module scope. This allows to refer to them directly:

function foo() { console.log('foo') }
function bar() { console.log('bar') }
function baz() { foo(); bar() }

export default {foo, bar, baz}

And if you want the convenience of default export and ability to import items individually, you can also export all functions individually:

// util.js

export function foo() { console.log('foo') }
export function bar() { console.log('bar') }
export function baz() { foo(); bar() }

export default {foo, bar, baz}

// a.js, using default export

import util from './util'
util.foo()

// b.js, using named exports

import {bar} from './util'
bar()

Or, as @loganfsmyth suggested, you can do without default export and just use import * as util from './util' to get all named exports in one object.

2 of 4
31

One alternative is to change up your module. Generally if you are exporting an object with a bunch of functions on it, it's easier to export a bunch of named functions, e.g.

export function foo() { console.log('foo') }, 
export function bar() { console.log('bar') },
export function baz() { foo(); bar() }

In this case you are export all of the functions with names, so you could do

import * as fns from './foo';

to get an object with properties for each function instead of the import you'd use for your first example:

import fns from './foo';
Discussions

Nodejs - how group and export multiple functions in a separate file?
How can I group and export multiple functions in nodejs? I am trying to group all my util functions in utils.js: async function example1 () { return 'example 1' } async function example2 () ... More on stackoverflow.com
🌐 stackoverflow.com
Exporting multiple functions with module.exports in ES6
I'm building a node.js application and I'm trying to put all my mongodb logic in a seperate file. At this time this file only has one function to initialize the mongodb connection. I want to export... More on stackoverflow.com
🌐 stackoverflow.com
How to export multiple functions ES6 - javascript
What I need to know: How can I export my sendData()? They used a short syntax so far because they only exported one function. How can I export multiple functions? More on stackoverflow.com
🌐 stackoverflow.com
javascript - Exporting multiple functions with arguments
You're making it more complex than needed. Once you have your functions defined, you can export it with this: ... What you're exporting from the module is an object (which I've named init in the example above) that contains two functions. More on stackoverflow.com
🌐 stackoverflow.com
🌐
Atomizedobjects
atomizedobjects.com › blog › javascript › how-to-export-multiple-functions-in-javascript
How to export multiple functions in JavaScript | Atomized Objects
August 27, 2021 - All you have to do is apply the statement before each of your function definitions and as long as you are using JavaScript with ES6 or later which most modern projects will be, then the functions will be exported. You can use the export statement as many times as you like in a single file.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Statements › export
export - JavaScript - MDN Web Docs
July 29, 2025 - After the export keyword, you can use let, const, and var declarations, as well as function or class declarations. You can also use the export { name1, name2 } syntax to export a list of names declared elsewhere.
🌐
YouTube
youtube.com › watch
Exporting Multiple JavaScript Functions from a Node Module - YouTube
We are going to build on our last tutorial and look at how you can export more than one item from a node module. This is done using an object.For more resour...
Published   January 30, 2019
🌐
ProgrammingBasic
programmingbasic.com › home › javascript › javascript - how to export multiple functions from a file
JavaScript - How to export multiple functions from a file | ProgrammingBasic
However, if you are not using ES6 or a later version in your project, then you have to use the module.exports to export multiple functions from a file. For example:
🌐
Restack
restack.io › p › node-js-export-multiple-functions-answer-cat-ai
Node.js Export Multiple Functions ES6 | Restackio
March 27, 2025 - Learn how to export multiple functions in Node.js using ES6 syntax for efficient media streaming applications. | Restackio
Find elsewhere
🌐
SitePoint
sitepoint.com › blog › javascript › understanding module.exports and exports in node.js
Understanding module.exports and exports in Node.js — SitePoint
January 29, 2024 - Then in the index.js file, we’re importing this function and executing it. Also notice that in the require statement, the module name is prefixed with ./, as it’s a local file. Also note that there’s no need to add the file extension. We can export multiple methods and values in the same way:
🌐
The Knowledge Academy
theknowledgeacademy.com › blog › export-in-nodejs
Exports in Nodejs: A Guide
December 26, 2025 - In this example, three functions (add, subtract, and multiply) are exported using the ‘export’ keyword, allowing them to be accessed by name when importing the module.
🌐
Stack Abuse
stackabuse.com › how-to-use-module-exports-in-node-js
How to use module.exports in Node.js
July 8, 2024 - Therefore, we can export any value ... the module.exports object. For example, if we would like to export a variable named temperature, we could make it available for use outside the module by simply adding it as a new property of module.exports as follows:...
🌐
LaunchCode
education.launchcode.org › intro-to-professional-web-dev › chapters › modules › exporting.html
13.4. Exporting Modules — Introduction to Professional Web Development in JavaScript documentation
We do not have to make the key match the name of the function, but doing so helps maintain consistency between files. ... This will NOT work, because Node expects only ONE module.exports statement in a file.
🌐
KnowledgeHut
knowledgehut.com › home › blog › web development › how to export node.js modules using exports
How to Export Node.js Modules Using Exports
September 13, 2023 - Use module.exports for exporting multiple items and use exports to export single items easily. ... Yes, they are similar in performance and result but different in syntax. Their items can be imported similarly as well. ... Modules in NodeJs are a method of organizing blocks of code, functions, objects, and classes for code-sharing, reusability, and maintainability.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-export-multiple-values-or-elements-in-a-module
How to export multiple values or elements in a Module ? - GeeksforGeeks
June 18, 2024 - export let element1 export const someValue export function foo(){...} Note: As we are exporting multiple values, while importing those values it is mandatory to use the same name of the corresponding object.
🌐
Itsourcecode
itsourcecode.com › home › how to export multiple functions in javascript
How to Export Multiple Functions in JavaScript
August 18, 2023 - In each file, use the module.exports objects to export the functions you want to make available to other parts of your application. ... In the file where you need these functions, use the required function to import them.
🌐
Codingem
codingem.com › home › how to export multiple functions in javascript
How to Export Multiple Functions in JavaScript - codingem.com
July 10, 2025 - To export multiple functions in JavaScript, call export by comma-separating the functions in curly braces. For example export { f1, f2, f3 }