algoliasearch-client-javascript icon indicating copy to clipboard operation
algoliasearch-client-javascript copied to clipboard

Angular 6 Uncaught ReferenceError: process is not defined

Open diegofin opened this issue 8 years ago • 8 comments

UPDATE FROM MAINTAINERS

The working workaround for this issue for now is to add:

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

/UPDATE FROM MAINTAINERS

to your polyfill.ts file in you Angular app

Do you want to request a feature or report a bug? Bug What is the current behavior? Angular does not provide a shim for "process" anymore (https://github.com/angular/angular-cli/issues/9827#issuecomment-369578814).

Error:

Uncaught ReferenceError: process is not defined
    at Object../node_modules/algoliasearch/src/AlgoliaSearchCore.js (vendor.js:175349)
    at __webpack_require__ (runtime.js:82)
    at Object../node_modules/algoliasearch/src/AlgoliaSearch.js (vendor.js:174675)
    at __webpack_require__ (runtime.js:82)
    at Object../node_modules/algoliasearch/src/browser/builds/algoliasearch.js (vendor.js:177945)
    at __webpack_require__ (runtime.js:82)
...

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. Just using the library in an Angular 6 throws the error

What is the expected behavior? To use algoliasearch library in an Angular 6 app

diegofin avatar May 05 '18 15:05 diegofin

Hey @diegotham, I think I have a fix for this (https://github.com/algolia/algoliasearch-client-javascript/pull/692), but to test it out correctly, I’d need to check in a real app, would it be possible for you to give a minimal reproduction in a GitHub repo please? Thanks!

Haroenv avatar May 05 '18 16:05 Haroenv

Same issue.

danduh avatar May 08 '18 09:05 danduh

Workaround: const algoliasearch = require ('algoliasearch/dist/algoliasearch.js');. Most likely, the problem with the fact that in package.json in browser not those paths are specified.

0x6368656174 avatar May 09 '18 09:05 0x6368656174

Yes, @0x6368656174, both that would work, as well as const algoliasearch = require ('algoliasearch/dist/algoliasearchLite.min.js'); for a smaller version.

Note that you can also shim process as described in https://github.com/algolia/angular-instantsearch/issues/90#issuecomment-387028504 in polyfill.ts:

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

Haroenv avatar May 09 '18 09:05 Haroenv

I'm also getting the same issue

ArsalRaza avatar May 24 '18 03:05 ArsalRaza

Same here

trsh avatar May 24 '18 12:05 trsh

Did you read the workaround @ArsalRaza @trsh ?

Haroenv avatar May 24 '18 13:05 Haroenv

The working workaround for this issue for now is to add:

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

to your polyfill.ts file in you Angular app, locking this issue since the workaround is easy for now. Until we find the right solution.

vvo avatar May 25 '18 08:05 vvo