question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CLI breaks when hitting SVGs

See original GitHub issue

When the directory contains an svg file the CLI stops with the following error.

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received undefined
    at Object.statSync (node:fs:1529:10)
    at /Users/###/node_modules/@funboxteam/optimizt/lib/optimize.js:76:18
    at Array.forEach (<anonymous>)
    at optimize (/Users/###/node_modules/@funboxteam/optimizt/lib/optimize.js:74:15)
    at async optimizt (/Users/###/node_modules/@funboxteam/optimizt/index.js:18:5) {
  code: 'ERR_INVALID_ARG_TYPE'
}

When I add filtering for errors via const tasksResult = (await Promise.all(tasks)).filter(res => !!res); in optimize.js I see the following output for those svg files:

✖ /Users/###/src/images/###.svg
   parseName is not a function

The SVG issue might be introduced in https://github.com/funbox/optimizt/commit/f4510cb139c047e4eb84a2e80915d4daca1b4d09.

But error filtering should be applied in any case.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
edziscommented, Sep 23, 2021

👌 this works now and processes also the svg files! Thanks for your care! I wish I had raised my concerns about require('../node_modules/svgo/... earlier.

1reaction
edziscommented, Sep 23, 2021

@igoradamenko @343dev There seems to be another issue:

➜  my-project git:(develop) optimizt ./src
node:internal/modules/cjs/loader:928
  throw err;
  ^

Error: Cannot find module '../node_modules/svgo/lib/xast.js'
Require stack:
- /Users/X/.config/yarn/global/node_modules/@funboxteam/optimizt/svgo/removeUnknownsAndDefaults.js
- /Users/X/.config/yarn/global/node_modules/@funboxteam/optimizt/svgo/config.js
- /Users/X/.config/yarn/global/node_modules/@funboxteam/optimizt/lib/optimize.js
- /Users/X/.config/yarn/global/node_modules/@funboxteam/optimizt/index.js
- /Users/X/.config/yarn/global/node_modules/@funboxteam/optimizt/cli.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:925:15)
    at Function.Module._load (node:internal/modules/cjs/loader:769:27)
    at Module.require (node:internal/modules/cjs/loader:997:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at Object.<anonymous> (/Users/X/.config/yarn/global/node_modules/@funboxteam/optimizt/svgo/removeUnknownsAndDefaults.js:4:45)
    at Module._compile (node:internal/modules/cjs/loader:1108:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
    at Module.load (node:internal/modules/cjs/loader:973:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Module.require (node:internal/modules/cjs/loader:997:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/X/.config/yarn/global/node_modules/@funboxteam/optimizt/svgo/removeUnknownsAndDefaults.js',
    '/Users/X/.config/yarn/global/node_modules/@funboxteam/optimizt/svgo/config.js',
    '/Users/X/.config/yarn/global/node_modules/@funboxteam/optimizt/lib/optimize.js',
    '/Users/X/.config/yarn/global/node_modules/@funboxteam/optimizt/index.js',
    '/Users/X/.config/yarn/global/node_modules/@funboxteam/optimizt/cli.js'
  ]
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

All SVGs on site now broken - WordPress.org
Hi there, All SVGs on my site are now broken and no longer appearing. Did something change recently? ... You can do this...
Read more >
5 Most Common Problems Faced by SVG Users - Vecta.io
1. Missing fonts · A. Wrongly declared font name · B. You're using <img> or background image to embed your SVG · C....
Read more >
Three Ways of Decreasing SVG File Size with SVGO - SitePoint
The big advantage of not being pixel-based is that SVGs look ... However, you need to use your computer's command line user interface...
Read more >
Production build optimization breaks code #11439 - GitHub
The optimization step should optimize, but never break code. ... should be written, the CLI should try not to break existing code, instead....
Read more >
Clipping in CSS and SVG — The clip-path Property and ...
Both CSS and SVG allow us to "clip" elements into custom non-rectangular shapes. In this article we will go over the clipping techniques...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found