Needed dependency '@resvg/resvg-js-linux-x64-gnu' marked as optional
userjoergjakoby opened this issue · comments
We did an update of svg-sprite from version 1.5.4 to version 2.0.2 and afterwards we had the issue that our build failed with the error message:
2022-11-29 14:11:07.527 - error: Optimizing "setting.svg" with SVGO failed with error "Error: Cannot find module '@resvg/resvg-js-linux-x64-gnu'.
Our CI uses npm ci --omit=optional
to skip dependencies necessary only on developer machines.
In this case however, the @resvg dependencies are necessary to the build with svg-sprite, which is why they should not be marked as optional.
@yisibl Hello! Can you please check this? I think optionalDependencies
can't be omited in resvg package. What can you suggest? Thanks
We're facing the same issue in our atos-parallel project...
It seems that this is the intended behavior from napi-rs though.
We use optional dependencies for developer helper tools like commit hooks.
Since those dependencies are not necessary on CI, we skip installing them to save time and bandwidth.
Being forced to install all optional dependencies would have a negative impact on our CI.
So a solution on resvg-js level would be highly appreciated
If don't distribute native addons with optionalDependencies
, the only other way is to distribute it with postinstall
scripts, which is harmful to the developer experience and also introduces unnecessary dependencies for runtime (only for download binaries in postinstall), and can't be omitted at all.
There is an RFC in npm which may solve this problem in future: npm/rfcs#519