That is not valid syntax. You can do

export { Post }

or even just

export var Post = Parse.Object.extend('Post')

or shorten the whole file to

export default Parse.Object.extend('TestObject')
export var Post = Parse.Object.extend('Post')

Your imports are also incorrect, you'll want to do

import TestObject, { Post } from '../store'

This is if you really want a single default export and a separate named export. You can also just make two named exports and have no default if you want, e.g.

export var TestObject = Parse.Object.extend('TestObject');
export var Post = Parse.Object.extend('Post');

or

var TestObject = Parse.Object.extend('TestObject');
var Post = Parse.Object.extend('Post');
export { TestObject, Post };

and import with

import { TestObject, Post } from '../store'
Answer from loganfsmyth on Stack Overflow
🌐
Esdiscuss
esdiscuss.org › topic › why-is-export-default-var-a-1-invalid-syntax
Why is "export default var a = 1;" invalid syntax?
You can already do "var a = 1;export default a;”. Why not >> make "export default var a = 1;” valid? >> > > Exporting a variable declaration list as "default" wouldn't make sense: > for one, the list can have more than one element: > > export default var a, b, c; // Non-sensical > > > > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > -------------- next part -------------- An HTML attachment was scrubbed...
Discussions

Export more than one variable in ES6?
So the default keyword is not required anymore? 2016-01-07T01:14:09.413Z+00:00 ... Correct @alexchenco, you de-structure the imported file instead. 2016-01-07T01:14:58.563Z+00:00 ... Save this answer. Show activity on this post. In order to export multiple variables we have to take everything ... More on stackoverflow.com
🌐 stackoverflow.com
July 1, 2016
Why Is `Export Default Const` invalid? - javascript
With export default, you don't ... the variable. ... JavaScript does not support export default along with const. export default can be used along with expressions, functions and classes. ... It is because we cannot identify which is the default out of a and b at the time of import. ... Note: Although only 1 export default is allowed in a JavaScript module, multiple exports are ... More on stackoverflow.com
🌐 stackoverflow.com
Can I export default from a variable? - javascript
I would like to change my export { default } from 'MyFile' depending on certain conditions, so can I replace the file with a string variable? More on stackoverflow.com
🌐 stackoverflow.com
reactjs - ES6 how to do multiple default exports - Stack Overflow
I am still getting a hang of react+redux, and ES6. I am trying to implement socketio, and I come across the problem of having to export socketio connect with my redux's connect. redux connect exp... More on stackoverflow.com
🌐 stackoverflow.com
🌐
DEV Community
dev.to › deogadkarravina › javascript-export-and-export-default-5dd6
Javascript: export and export default - DEV Community
August 29, 2020 - We can use export from, to export variables from parent module, which is in turn importing from multiple modules. Consider childmodule1 is exporting a variable myvar and childmodule2 is exporting a function myfunc.
🌐
JavaScript.info
javascript.info › tutorial › the javascript language › modules
Export and Import
Modules provide a special export default (“the default export”) syntax to make the “one thing per module” way look better.
🌐
Atomizedobjects
atomizedobjects.com › blog › javascript › how-to-export-multiple-functions-in-javascript
How to export multiple functions in JavaScript | Atomized Objects
August 27, 2021 - In this post we are going to look at everything you need to know to be able to export multiple functions in a JavaScript file, and even multiple variables. To export multiple functions in JavaScript, the easiest way to do so is by using the export statement before each function you want to export. ...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Statements › export
export - JavaScript - MDN Web Docs
Every module can have two different types of export, named export and default export. You can have multiple named exports per module but only one default export.
🌐
Medium
medium.com › @drtechpunk › export-vs-export-default-in-javascript-c4ae8fa4b0c
Export vs Export Default in JavaScript | by DrTechPunk | Medium
December 22, 2023 - export default: Use export default when you want to export a single value from a module, which will be the default export. This can be a variable, function, class, or object.
Find elsewhere
🌐
Exploring JS
exploringjs.com › es6 › ch_modules.html
16. Modules
There are two kinds of exports: named exports (several per module) and default exports (one per module). As explained later, it is possible use both at the same time, but usually best to keep them separate. A module can export multiple things by prefixing its declarations with the keyword export.
Top answer
1 of 8
531

const is like let, it is a LexicalDeclaration (VariableStatement, Declaration) used to define an identifier in your block.

You are trying to mix this with the default keyword, which expects a HoistableDeclaration, ClassDeclaration or AssignmentExpression to follow it.

Therefore it is a SyntaxError.


If you want to const something you need to provide the identifier and not use default.

export by itself accepts a VariableStatement or Declaration to its right.


The following is fineexport default Tab;

Tab becomes an AssignmentExpression as it's given the name default ?

export default Tab = connect( mapState, mapDispatch )( Tabs ); is fine

Here Tab = connect( mapState, mapDispatch )( Tabs ); is an AssignmentExpression.


Update: A different way to imagine the problem

If you're trying to conceptually understand this and the spec-reasoning above is not helping, think of it as "if default was a legal identifier and not a reserved token, what would be a different way to write export default Foo; and export default const Foo = 1; ?"

In this situation, the expanded way to write it would be

// pseudocode, this thought experiment is not valid JS

export default Foo;
// would be like
export const default = Foo;

export default const Foo = 1;
// would be like
export const default const Foo = 1;
// so would the following line make sense?
const bar const Foo = 1;

There is a valid argument the expansion should be something like

// pseudocode, this thought experiment is not valid JS

export default const Foo = 1;
// would be like
const Foo = 1;
export const default = Foo;

However, this then would become ambiguous per Sergey's comment, so it makes more sense to write this pattern explicitly instead.

2 of 8
95

You can also do something like this if you want to export default a const/let, instead of

const MyComponent = ({ attr1, attr2 }) => (<p>Now Export On other Line</p>);
export default MyComponent

You can do something like this, which I do not like personally.

let MyComponent;
export default MyComponent = ({ }) => (<p>Now Export On SameLine</p>);
🌐
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 - Exporting multiple values from a Node.js module can be done in various ways, each with its own advantages. Using module.exports to export an object is the most common and flexible approach, but you can also use the exports object for individual exports or mix both methods.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › difference-between-default-named-exports-in-javascript
Difference Between Default & Named Exports in JavaScript - GeeksforGeeks
August 5, 2025 - Default exports in JavaScript allow a module to export a single value or entity as the default export. Unlike named exports, which allow you to export multiple values from a module, default exports allow you to export only one value per module.
🌐
freeCodeCamp
freecodecamp.org › news › difference-between-default-and-named-exports-in-javascript
What's the Difference Between Default and Named Exports in JavaScript?
August 14, 2023 - This enables you to reuse and promote a modular and organized code structure. In JavaScript, there are two main ways to export values: default exports, used for a single value per file, and named exports, allowing multiple exports per file.
🌐
Devcamp
utahedu.devcamp.com › cts-2018 › guide › guide-default-exports-javascript
Guide to Default Exports in JavaScript
I'm going to come into our helper file here and I'm going to copy all this code and I'm going to paste it inside of here. So a ruled that we have in JavaScript is you cannot have multiple default exports in a file and if you think about it that's just logical.
🌐
DhiWise
dhiwise.com › post › the-ultimate-guide-to-react-export-multiple-functions
React Export Multiple Functions
October 22, 2024 - An 'import statement' is utilized ... multiple imports in a single line for efficient code organization. Yes, you can export multiple functions in React....
🌐
Codecademy Forums
discuss.codecademy.com › frequently asked questions › javascript faq
Why would I want to combine named exports with default exports?
December 8, 2018 - Question Why would I want to combine named exports with default exports? Answer We combine named exports and default exports when we want to give a module the ability to define the default export of the module and other…
🌐
LinkedIn
linkedin.com › pulse › javascript-module-exports-default-vs-named-ayman-anaam
JavaScript Module Exports: Default vs. Named Exports
August 16, 2023 - Default exports are used to export a single "main" value from a module, while named exports allow us to export multiple values with specific names.
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';