# TypeError: concurrently(...).then is not a function

**URL:** <https://community.apollographql.com/t/typeerror-concurrently-then-is-not-a-function/6305>\
**Category:** About the Community\
**Tags:** odyssey\
**Created:** [May 26, 2023, 7:20am UTC](https://community.apollographql.com/t/typeerror-concurrently-then-is-not-a-function/6305 "2023-05-26T07:20:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![xibaozhi0](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/xibaozhi0/32/4318_2.png) [@xibaozhi0](https://community.apollographql.com/u/xibaozhi0)\
**Post date:** [May 26, 2023, 7:20am UTC](https://community.apollographql.com/t/typeerror-concurrently-then-is-not-a-function/6305/1 "2023-05-26T07:20:51Z")

</div>

I got message"TypeError: concurrently(…).then is not a function",the code is \odyssey-voyage-II-server-main\monolith\utils\launch:"

const concurrently = require(‘concurrently’);  
const path = require(‘path’);  
concurrently(  
[  
{  
command: ‘npm start’,  
name: ‘accounts’,  
cwd: path.resolve(\_\_dirname, ‘…/…/services/accounts’),  
prefixColor: ‘blue’,  
},  
{  
command: ‘npm start’,  
name: ‘listings’,  
cwd: path.resolve(\_\_dirname, ‘…/…/services/listings’),  
prefixColor: ‘magenta’,  
},  
{  
command: ‘npm run booking:update’,  
name: ‘bookings’,  
cwd: path.resolve(\_\_dirname, ‘…/…/services/bookings’),  
prefixColor: ‘green’,  
},  
],  
{  
prefix: ‘name’,  
killOthers: [‘failure’],  
restartTries: 3,  
}  
).then(  
function onSuccess() {  
// This code is necessary to make sure the parent terminates  
// when the application is closed successfully.  
process.exit();  
},  
function onFailure(exitInfo) {  
console.log(exitInfo);  
// This code is necessary to make sure the parent terminates  
// when the application is closed because of a failure.  
process.exit();  
}  
);

"

chatgpt  
The error message you received, “TypeError: concurrently(…).then is not a function,” suggests that the concurrently function does not return a promise that can be chained with .then().

In the code you provided, it seems that you are using the concurrently package to run multiple commands concurrently. The concurrently function does not return a promise by default, so you cannot use .then() on it.

If you want to execute some code after the concurrently operation is completed, you can provide a callback function as the third argument to the concurrently function. Here’s an updated version of your code:

javascript  
Copy code  
const concurrently = require(‘concurrently’);  
const path = require(‘path’);

concurrently(  
[  
{  
command: ‘npm start’,  
name: ‘accounts’,  
cwd: path.resolve(\_\_dirname, ‘…/…/services/accounts’),  
prefixColor: ‘blue’,  
},  
{  
command: ‘npm start’,  
name: ‘listings’,  
cwd: path.resolve(\_\_dirname, ‘…/…/services/listings’),  
prefixColor: ‘magenta’,  
},  
{  
command: ‘npm run booking:update’,  
name: ‘bookings’,  
cwd: path.resolve(\_\_dirname, ‘…/…/services/bookings’),  
prefixColor: ‘green’,  
},  
],  
{  
prefix: ‘name’,  
killOthers: [‘failure’],  
restartTries: 3,  
},  
(exitCodes, signal) =\> {  
if (exitCodes && exitCodes.some(code =\> code !== 0)) {  
console.log(‘Error occurred during execution.’);  
process.exit(1);  
} else {  
console.log(‘All commands completed successfully.’);  
process.exit(0);  
}  
}  
);  
In this updated code, the callback function (exitCodes, signal) =\> { … } is called once the concurrently operation is finished. It checks the exitCodes to determine if any command failed (exit code is not 0), and then you can handle the success or failure accordingly.

Note that the exit() calls within the callback are necessary to ensure that the parent process terminates when the application is closed successfully or due to a failure.

---

<div class="post-metadata">

**Author:** ![Michelle\_Mabuyo](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/michelle_mabuyo/32/80_2.png) [@Michelle\_Mabuyo](https://community.apollographql.com/u/Michelle_Mabuyo)\
**Post date:** [May 26, 2023, 2:15pm UTC](https://community.apollographql.com/t/typeerror-concurrently-then-is-not-a-function/6305/2 "2023-05-26T14:15:33Z")

</div>

Hi @xibaozhi0 ! This typically happens when you haven’t installed the necessary packages.

In the `monolith` folder, make sure to run `npm i`. Then, run `npm run launch` to start the services.

Can you also confirm what version of node you’re using with `node -v`?

Hope that helps!

---

<div class="post-metadata">

**Author:** ![xibaozhi0](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/xibaozhi0/32/4318_2.png) [@xibaozhi0](https://community.apollographql.com/u/xibaozhi0)\
**Post date:** [May 27, 2023, 1:56am UTC](https://community.apollographql.com/t/typeerror-concurrently-then-is-not-a-function/6305/3 "2023-05-27T01:56:45Z")

</div>

sorry, I use node 18.16.0. maybe I use command “npm start” first. serval month ago, I did not meet any error message, this time an error message came to me. sorry

---

<div class="post-metadata">

**Author:** ![Michelle\_Mabuyo](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/michelle_mabuyo/32/80_2.png) [@Michelle\_Mabuyo](https://community.apollographql.com/u/Michelle_Mabuyo)\
**Post date:** [May 30, 2023, 5:14pm UTC](https://community.apollographql.com/t/typeerror-concurrently-then-is-not-a-function/6305/4 "2023-05-30T17:14:21Z")

</div>

No worries! Is it working for you after running `npm i` _then_ `npm run launch` in the `monolith` folder? Or are you still stuck with that error?

---

<div class="post-metadata">

**Author:** ![Justin\_Gonzalez](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/justin_gonzalez/32/5359_2.png) [@Justin\_Gonzalez](https://community.apollographql.com/u/Justin_Gonzalez)\
**Post date:** [February 6, 2025, 8:48pm UTC](https://community.apollographql.com/t/typeerror-concurrently-then-is-not-a-function/6305/5 "2025-02-06T20:48:51Z")

</div>

Archived on February 6, 2025, 8:48pm UTC


