open-cli-tools / concurrently

Run commands concurrently. Like `npm run watch-js & npm run watch-less` but better.
https://www.npmjs.com/package/concurrently
MIT License
7k stars 228 forks source link

Build failed when using concurently #432

Closed cojoclaudiu closed 6 months ago

cojoclaudiu commented 1 year ago

Hello, I'm building my projects using concurently but recently my builds fail with this error

yarn run v1.22.19
$ concurrently --kill-others-on-fail "yarn build:app1" "yarn build:app2"
/node_modules/cliui/build/index.cjs:293
const wrap = require('wrap-ansi');
             ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /node_modules/wrap-ansi/index.js from /Users/claudiu.cojocaru/node_modules/cliui/build/index.cjs not supported.
Instead change the require of index.js in /node_modules/cliui/build/index.cjs to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/node_modules/cliui/build/index.cjs:293:14)
    at Object.<anonymous> (/node_modules/yargs/build/index.cjs:1:60678)
    at Object.<anonymous> (/node_modules/yargs/index.cjs:5:30)
    at Object.<anonymous> (/node_modules/concurrently/dist/bin/concurrently.js:30:33) {
  code: 'ERR_REQUIRE_ESM'
}
error Command failed with exit code 1.

I'm using "concurrently": "^8.2.0"

Thank you

gustavohenke commented 1 year ago

Can you provide any more details?

Also note that concurrently doesn't use either of the mentioned packages (cliui and wrap-ansi), so without a minimal reproduction code, I'm unlikely to be able to help.

joneath commented 1 year ago

I'm also facing the same issue but I don't believe concurrently is the cause as @gustavohenke said. Locally my dev server fails to boot with concurrently being the top of the stack for the trace but when I try and build my project in Github actions it fails on cypress. This all occurred last week when I updated a lot of packages so now I get to filter out which one. I'll report back here on which package it was so maybe @cojoclaudiu has the same one and can rollback versions.

cojoclaudiu commented 1 year ago

@joneath are you using rimraf? I've have this problem when I've got concurrently and rimraf installed, if I remove rimref the error is gone

joneath commented 1 year ago

I don't have rimraf as a direct dependency but it's included in my yarn.lock as a packaged dependency. My project uses Nuxt and after reverting from the 3.6.x release back to 3.5.3 while also restoring the yarn.lock fixed the issue. I may dig in a bit more to see why the upgrade breaks by project but I may also just wait until the next Nuxt release and try my luck then...

ueat-benoitt commented 1 year ago

I got the exact same error. Looking at the lock file, it was supposed to use wrap-ansi@7 but it was using wrap-ansi@v8 even though the lock file was saying otherwise. I had to delete yarn.lock and node_modules and re-run yarn. It's the only way I was able to fix it. Luckily my versions were not too out of date.

kgarchie commented 1 year ago

I have the same issue. I use Nuxt

paescuj commented 1 year ago

I have the same issue. I use Nuxt

Also with the latest version? https://github.com/open-cli-tools/concurrently/releases/tag/v8.2.1

kgarchie commented 1 year ago

I have the same issue. I use Nuxt

Also with the latest version? https://github.com/open-cli-tools/concurrently/releases/tag/v8.2.1

Yeap, but I reckon that the problem may lie in Nuxt

paescuj commented 1 year ago

Yea

I have the same issue. I use Nuxt

Also with the latest version? https://github.com/open-cli-tools/concurrently/releases/tag/v8.2.1

Yeap, but I reckon that the problem may lie in Nuxt

Yeah, I guess it's because of conflicting versions of wrap-ansi in the dependency tree and somehow the wrong version gets required.

NobbZ commented 8 months ago

I had this problem using the following dependencies in my SSG for a blog I am preparing:

{
  "dependencies": {
    "@tailwindcss/typography": "^0.5.10",
    "tailwindcss": "^3.4.1"
  },
  "devDependencies": {
    "concurrently": "^8.2.2"
  }
}

Perhaps this more minimal list of deps can help to identify the problem.

In the meantime I was able to mitigate by removing concurrently from the deps and using it installed from my systems package manager, even though this feels unclean.

gustavohenke commented 8 months ago

Hey @NobbZ, do you mind also sharing your package-lock.json, Node.js and package manager version (npm/pnpm/yarn)?

NobbZ commented 8 months ago

I never committed that and reverted already to only tailwind.

I will try to reproduce later this evening and then provide what I get.

NobbZ commented 8 months ago

I created a gist at https://gist.github.com/NobbZ/df3b2c3491cbb2ae85bdfe88df8ffaa6 that should contain the required information. If anything is missing please ask and I will try to provide it.

houd1ni commented 6 months ago

@NobbZ Had to uninstall concurrently because of this. No adequate hacks that works. It also might just work if the package maintainer just upgrade their deps.

cojoclaudiu commented 6 months ago

@houd1ni you can still use it if you add to resolutions the dependencies version

houd1ni commented 6 months ago

@houd1ni you can still use it if you add to resolutions the dependencies version

A lot of. I've tracked and added two and more came up. Three and more looks dangerous for me 😄

gustavohenke commented 6 months ago

Thanks @NobbZ for the reproduction. I managed to reproduce it without using nix.

There are some issues about this on yargs and cliui about this:

Seems like this issue is related to yarn <1.22.22. Once I upgraded yarn, the issue is fixed. https://github.com/yarnpkg/yarn/releases/tag/v1.22.22