astro-imagetools: Cannot find package 'object-hash'

Astro build leads to object-hash error with Astro 2.0.0-beta.1

Cannot find package 'object-hash' imported from /Volumes/Evo/Sites/astro-content/dist/entry.mjs
  Did you mean to import object-hash@3.0.0/node_modules/object-hash/index.js?

Therefore, I tried installing object-hash as a separate package, but then I ended up with a different error in regards to unmet peer dependencies which made more sense since Astro 2 beta is quite new.

Regardless, if I downgrade to Astro 1.9.x, my project does compile.

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 3
  • Comments: 17 (2 by maintainers)

Commits related to this issue

Most upvoted comments

Hello, what is the best practice for using astro-imagetools witn pnpm? I tried with shamefully-hoist=true but it didn’t help.

error Cannot find package 'object-hash' imported from C:\www\2023\test\dist\chunks\pages\_slug__d8e98270.mjs Did you mean to import object-hash@3.0.0/node_modules/object-hash/index.js? Error: Cannot find package 'object-hash' imported from C:\www\2023\test\dist\chunks\pages\_slug__d8e98270.mjs

dev mode works fine, but with the build there is a issue.

i tried with adding additional vite configs to astro.config.mjs but it allso doesn’t work.

I removed node_modules and installed all using: pnpm install --shamefully-hoist --> now it works.

@xav-ie I really don’t know much about pnpm, but adding a .npmrc file with shamefully-hoist=true to the root of the project seems to have magically cleared up any remaining issues. Both build and preview work without a problem.

I’ve updated my march-update branch to reflect this; now using pnpm.

I also wanted to confirm my personal Astro project builds without any issue as well.

@xav-ie After updating to Astro 2.0.17 and Astro Imagetools 0.8.1 it looks like the issue is might just be pnpm related.

Using npm instead, all builds properly even without adding all those dependencies and having to add vite: { build: { assetsDir: "_astro"} } to the Astro config file.

I created a march-update branch which uses npm. https://github.com/djmtype/astro-imagetools-test/tree/march-update

This is still happening with Astro 2.0.4