oslllo / svg-fixer

Converts SVG Strokes To Fill.
https://docs-oslllo-com.onrender.com/svg-fixer/master
MIT License
215 stars 20 forks source link

TypeError using node v16 or earlier #97

Closed aethr closed 10 months ago

aethr commented 10 months ago

Version details

Package version: 3.0.0 node version: 16.13.2

Issue

Running oslllo-svg-fixer or importing the package into a .js file throws the error:

$ node -v
v16.13.2

$ oslllo-svg-fixer
/project_path/node_modules/piscina/dist/src/index.js:804
class Piscina extends events_1.EventEmitterAsyncResource {
                               ^

TypeError: Class extends value undefined is not a constructor or null
    at Object.<anonymous> (/home/linds/Code/gomi/lindsay/fix-svg/node_modules/piscina/dist/src/index.js:804:32)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/linds/Code/gomi/lindsay/fix-svg/node_modules/oslllo-svg-fixer/src/processor.js:6:17)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)

Root cause

It seems that the version of piscina package used in the project no longer supports node v16 or earlier, due to using a built-in version of EventEmitterAsyncResource.

Workaround

The fix is simply to use node v18 or higher:

$ node -v
v18.12.1

$ oslllo-svg-fixer
Usage: oslllo-svg-fixer [source] [destination] [options]

Options:
      --version                   Show version number                  [boolean]
  -s, --source                    path containing SVG(s).    [string] [required]
  -d, --destination               path to store fixed SVG(s).[string] [required]
      --strict-destination, --sd  throw if destination path does not exist.
                                                       [boolean] [default: true]
      --show-progress, --sp       show progress bar in CLI.
                                                       [boolean] [default: true]
      --trace-resolution, --tr    resolution of trace image: larger == higher
                                  quality and slower processing
                                                         [number] [default: 600]
      --help                      Show help                            [boolean]

Missing required arguments: source, destination

No issue with this myself, but it might be worth updating the documentation. Hopefully anyone else who runs into this will find this issue.

Ghustavh97 commented 10 months ago

Thanks for the issue, it seems like all node 16 tests are passing but they are running on v16.20.2 as of writing this comment, so updating your node version should fix this. With that said, we will be dropping support for node 16 in v4 since its now deprecated so this will not be an issue then.