algoliasearch-client-javascript: npm package cannot be used in browser project

Do you want to request a feature or report a bug?

BUG

What is the current behavior?

I used algoliasearch package in my Angular project. When importing the module it throws an exception of Cannot read property ‘RESET_APP_DATA_TIMER’ of undefined

I found it is caused by the code in AlgoliaSearchCore.js:

var RESET_APP_DATA_TIMER =
  process.env.RESET_APP_DATA_TIMER && parseInt(process.env.RESET_APP_DATA_TIMER, 10) ||
  60 * 2 * 1000;

I think there is no way that browser environment can access process.env. Is it a bug or I’m using the package wrong?

If the current behavior is a bug, please provide all the steps to reproduce and a minimal JSFiddle example or a repository on GitHub that we can npm install and npm start.

download algoliasearch package by npm/yarn and import it in a browser project

What is the expected behavior?

algoliasearch is initialized without errors

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (7 by maintainers)

Most upvoted comments

Oh my… just deleted node_modules, reinstalled, and now I don’t have the errors anymore either. I give up haha.

Yes I can, thank you! https://github.com/internet4000/radio4000 — if you yarn; yarn start you should see the “process” error first. When I update it as mentioned above, the autocomplete.js “global is not defined” error appears instead.

@noslouch How the Ember App is configured? Are you using ember-auto-import? If yes, you can provide DefinePlugin to Webpack through the webpack option of ember-auto-import.

@Haroenv Thanks for your information! I’ve got this handled by providing a custom webpack config with DefinePlugin in my Angular project. Everything works now 😃