Algolia Search Blocking the Application

Good morning.

I have just installed Algolia and AlgoliaInstantSearch using the following commands:

npm install algoliasearch@3 angular-instantsearch@beta instantsearch.js
npm install --save-dev @types/algoliasearch

The application compiles without problems but when running the application won’t start and I get the following error in the browser console:

Uncaught ReferenceError: process is not defined
at Object…/node_modules/algoliasearch/src/AlgoliaSearchCore.js (AlgoliaSearchCore.js:13)
at webpack_require (bootstrap:84)
at Object…/node_modules/algoliasearch/src/browser/builds/algoliasearchLite.js (algoliasearchLite.js:3)
at webpack_require (bootstrap:84)
at Module…/node_modules/angular-instantsearch/ivy_ngcc/fesm2015/angular-instantsearch.js (angular-instantsearch.js:1)
at webpack_require (bootstrap:84)
at Module…/src/app/app.module.ts (app.module.ts:1)
at webpack_require (bootstrap:84)
at Module…/src/main.ts (main.ts:1)
at webpack_require (bootstrap:84)

Please any idea?
Thanks in advance
Juan Antonio Santana

Hi there!

This is a problem we’re aware of with algoliasearch@3, and for which you can find the explanation and solution here.

The workaround is to add the following code in the polyfill.ts file of you Angular app.

(window as any).process = {
  env: { DEBUG: undefined },
};

Additionally, I would strongly recommend that you use the latest version for our algoliasearch package. We no longer support v3, and v4 solves the issue you’re having without needing the workaround.

npm install algoliasearch

Best,

Thanks for your reply.

Is V4 released already?

Regards,
Juan Antonio Santana

Yes it is! If you run npm install algoliasearch, you’ll get v4.