Hydrogen + Algolia #711
-
Algolia Issue✘ [ERROR] No matching export in "node-modules-polyfills:crypto" for import "createHmac"When you try to implement the algolia as the docs says this error happens: ➜ hydrogen-storefront git:(main) ✗ yarn dev
yarn run v1.22.19
$ shopify hydrogen dev
✘ [ERROR] No matching export in "node-modules-polyfills:crypto" for import "createHmac"
node_modules/@algolia/client-search/dist/client-search.esm.js:4:9:
4 │ import { createHmac } from 'crypto';
╵ ~~~~~~~~~~
Build failed with 1 error:
node_modules/@algolia/client-search/dist/client-search.esm.js:4:9: ERROR: No matching export in "node-modules-polyfills:crypto" for import "createHmac"
🏁 Initial build: 755.472ms
🚥 MiniOxygen server started at http://localhost:3000 (http://localhost:3000) After some research, I found this issue and I replaced the import from XMLHttpRequest not foundAnd everything started working correctly, But when I tried to implement the InstantSearchSSR component, I started getting this error: ➜ hydrogen-storefront git:(main) ✗ yarn dev
yarn run v1.22.19
$ shopify hydrogen dev
🏁 Initial build: 743.888ms
🚥 MiniOxygen server started at http://localhost:3000 (http://localhost:3000)
StorefrontClient: Using a private storefront token is recommended for server environments. Refer to the authentication https://shopify.dev/api/storefront#authentication documentation for more details.
<ref *1> ReferenceError: XMLHttpRequest is not defined
at /Users/josemiguel/dev/jose/hydrogen-storefront/node_modules/algoliasearch/dist/algoliasearch-lite.esm.browser.js:818:39
at new Promise (<anonymous>)
at Object.send (/Users/josemiguel/dev/jose/hydrogen-storefront/node_modules/algoliasearch/dist/algoliasearch-lite.esm.browser.js:817:20)
at retry (/Users/josemiguel/dev/jose/hydrogen-storefront/node_modules/algoliasearch/dist/algoliasearch-lite.esm.browser.js:419:38)
at /Users/josemiguel/dev/jose/hydrogen-storefront/node_modules/algoliasearch/dist/algoliasearch-lite.esm.browser.js:432:16 {
error: [Circular *1]
}
<ref *1> ReferenceError: XMLHttpRequest is not defined
at /Users/josemiguel/dev/jose/hydrogen-storefront/node_modules/algoliasearch/dist/algoliasearch-lite.esm.browser.js:818:39
at new Promise (<anonymous>)
at Object.send (/Users/josemiguel/dev/jose/hydrogen-storefront/node_modules/algoliasearch/dist/algoliasearch-lite.esm.browser.js:817:20)
at retry (/Users/josemiguel/dev/jose/hydrogen-storefront/node_modules/algoliasearch/dist/algoliasearch-lite.esm.browser.js:419:38)
at /Users/josemiguel/dev/jose/hydrogen-storefront/node_modules/algoliasearch/dist/algoliasearch-lite.esm.browser.js:432:16 {
error: [Circular *1]
} Reference linkI know Algolia can work with Remix because I saw the Remix conf, and you can see it works in this example But maybe it's not working with hydrogen for some reason. Example
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
You can't use
Try adding this library in your But I can't even find a npm package with this name |
Beta Was this translation helpful? Give feedback.
You can't use
algoliasearch/dist/algoliasearch-lite.esm.browser
distribute. It is meant for browser side implementation and will not work on a Cloudflare worker.Try adding this library in your
package.json
as a dependency?But I can't even find a npm package with this name
node-modules-polyfills
, is there an alias setup? or npm package got removed? Maybe Algolia have answer?