unjs / webpackbar

Elegant ProgressBar and Profiler for Webpack 3 , 4 and 5
MIT License
2.07k stars 66 forks source link

v6 breaks node14 support #136

Closed blaaat closed 9 months ago

blaaat commented 10 months ago

Environment

Node 14

Reproduction

I'm using a nuxt 2 project

Describe the bug

ERROR arr.at is not a function

index.cjs:29 return arr.length > 0 ? arr.at(-1) : null;

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at

.at is supported starting at node v16.6

Package.json still required node14+ "engines": { "node": ">=14.21.3" }

Additional context

No response

Logs

No response

rickhc3 commented 10 months ago

I came across the same issue and managed to resolve it by using Yarn's resolutions field in my package.json. This approach allows you to override the version of a transitive dependency like webpackbar. Here's how you can do it:

Add the resolutions Field in package.json

In your package.json file, add a resolutions field specifying the version of webpackbar that you want to use. For example, if you want to force version 5.0.2, your package.json should include:

{
  // ... other configurations
  "resolutions": {
    "webpackbar": "5.0.2"
  }
}

Install Dependencies with Yarn

After adding the resolutions field, run yarn install in your project directory. Yarn will respect the specified resolutions and install webpackbar version 5.0.2, regardless of the version required by other dependencies.

Verify the Dependency Version

You can then check if the correct version of webpackbar is installed using yarn list webpackbar.

This method is straightforward with Yarn as it supports the resolutions field natively. However, remember that overriding dependency versions can sometimes lead to compatibility issues, so make sure to test your application thoroughly after making such changes.

Hope this helps!