imagetools: Failed to resolve entry for package "vite-imagetools"
Hi, after upgrading to v5.0.3 I get in a Laravel project the following error:
✘ [ERROR] Failed to resolve entry for package "vite-imagetools".
The package may have incorrect main/module/exports specified in its package.json: No known conditions for "." specifier in "vite-imagetools" package [plugin externalize-deps]
node_modules/esbuild/lib/main.js:1360:27:
1360 │ let result = await callback({
This error came from the "onResolve" callback registered here:
node_modules/esbuild/lib/main.js:1279:20:
1279 │ let promise = setup({
The plugin "externalize-deps" was triggered by this import
vite.config.js:8:27:
8 │ import { imagetools } from 'vite-imagetools';
Node: v19.9.0 OS: Mac M1, Ventura 13.3.1 (a)
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 2
- Comments: 15
Glad you got it working. I should clarify that approach is really just a temporary hack. You’d be much better off adding
"type": "module"to yourpackage.jsonand then converting your postcss and tailwind configs to use modern ESM syntax instead ofmodule.exportsIt’s because your project is building into the legacy CJS format and
vite-imagetools5.x is only available as an ESM module. You should migrate away from the legacy format by adding"type": "module"to yourpackage.jsonimportis the JS standard way of doing package imports.requireis something the Node team made up themselves beforeimportwas available. It’s a terrible mess that the ecosystem is in by having to support both. The sooner everyone is usingimportandrequireis completely dead, the better off we’ll all be. Projects need to start migrating by adding"type": "module"to theirpackage.json. There are tons of other libraries that will require the same from you (e.g. basically the entire Svelte ecosystem only supports ESM). This is just the first library you happened to encounter requiring it in your particular project, but it’s the way everything is going and you’ll be forced to migrate sooner or later.changing vite.config.ts to vite.config.mts works for qwik 😄