Comments (3)
I've been unable to reproduce this on Debian (Linux). I get the same error as you if the file indeed does not exist, but if I create the file, everything works as intended.
Can you please try the following and share the result, just to confirm 100% that this is indeed the scenario you've encountered:
(
# create a temp directory and cd to it (usually /tmp)
cd $(mktemp -d)
# create a mock svg
echo '<svg></svg>' > original.svg
# optimize the svg with svgo
npx svgo@latest original.svg
)
from svgo.
you right from tmp folder it works,
npx svgo@latest original.svg
--- xdebug {
cwd: '/private/var/folders/_z/vx08z2b93ylfqdxv3n2hp7qm0000gp/T/tmp.ALluj36Grh',
file: 'original.svg',
__dirname: '/Users/i/.npm/_npx/2be8efd978f68697/node_modules/svgo/lib/svgo'
}
original.svg:
Done in 3 ms!
0.006 KiB - 0% = 0.006 KiB
but if I run it from my yarn monorepo project
- file:
/Users/i/all_work/ck/dtv/app/libs/shared-icons/SVGs/search.svg
cd /Users/i/all_work/ck/dtv/app/libs/shared-icons/SVGs
npx svgo@latest search.svg
--- xdebug {
cwd: '/Users/i/all_work/ck/dtv/app/libs/shared-icons',
file: 'search.svg',
__dirname: '/Users/i/.npm/_npx/2be8efd978f68697/node_modules/svgo/lib/svgo'
}
Error: Error: no such file or directory 'search.svg'.
at checkOptimizeFileError (/Users/i/.npm/_npx/2be8efd978f68697/node_modules/svgo/lib/svgo/coa.js:497:7)
at /Users/i/.npm/_npx/2be8efd978f68697/node_modules/svgo/lib/svgo/coa.js:378:16
at async Promise.all (index 0)
at async Command.action (/Users/i/.npm/_npx/2be8efd978f68697/node_modules/svgo/lib/svgo/coa.js:262:7)
at async Promise.all (index 0)
from svgo.
so the problem in case of monorepo process.cwd()
is /Users/i/all_work/ck/dtv/app/libs/shared-icons/
- but expected to be
/Users/i/all_work/ck/dtv/app/libs/shared-icons/SVGs
from svgo.
Related Issues (20)
- cleanupAttrs in 'preset-default' overrides is not respected
- Improve node.children handling HOT 9
- Option to change props to React Pattern HOT 2
- Corrupted image from systemd-analyze after default optimization HOT 2
- Remove default values like stroke-dasharray="none" stroke-opacity="1" HOT 6
- Specific SVG causes SVGO to fail: TypeError: Cannot read properties of undefined (reading '0') Edit: Bug is worse than I thought, SVGO corrupts all SVGs before encountering the invalid SVG. HOT 3
- SVGO incorrectly compress my svg HOT 2
- Unbound namespace prefix: "xlink" HOT 2
- [cleanupIDs] symbol is incorrectly removed when its ID is *NOT* used by URL-encoded reference
- Missing a ';' after converting svg with png;base64 HOT 1
- SVGO 3.3.0 stopped working in the AWS environment with Node.js 20 HOT 2
- Version 3.3.0 break commonjs exports
- Package.exports types file specification missing HOT 2
- `package.json`/ `dist/svgo.browser.js` are no longer exported HOT 1
- Unable to install [email protected] HOT 3
- Option to resize SVGs to custom dimesnions HOT 2
- Remove consecutive points in linear path string if they have zero length or direction does not change HOT 1
- 'Cannot read properties of undefined' error in reflectPoint
- An idea to round/rewrite elements with gradient
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from svgo.