Angular 6 Uncaught ReferenceError: process is not defined
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
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!
Same issue.
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.
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 },
};
I'm also getting the same issue
Same here
Did you read the workaround @ArsalRaza @trsh ?
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.