Closed retyui closed 8 months ago
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
)
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
/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)
so the problem in case of monorepo process.cwd()
is /Users/i/all_work/ck/dtv/app/libs/shared-icons/
/Users/i/all_work/ck/dtv/app/libs/shared-icons/SVGs
Describe the bug
can'r use
svgo
withnpx
it complaint "no such file"To Reproduce
Expected behavior
work properly
Screenshots
...
Desktop (please complete the following information):
Additional context
...