Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular 6 Uncaught ReferenceError: process is not defined #691

Closed
diegotham opened this issue May 5, 2018 · 8 comments
Closed

Angular 6 Uncaught ReferenceError: process is not defined #691

diegotham opened this issue May 5, 2018 · 8 comments

Comments

@diegotham
Copy link

diegotham commented May 5, 2018

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 (angular/angular-cli#9827 (comment)).

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

Haroenv added a commit that referenced this issue May 5, 2018
Most environments (webpack, browserify) by default define `process` as a shim for it.

However, some environements don't supply it, so we should always guard against it not being defined

fixes #691

(should be tested in a real angular app first)
@Haroenv
Copy link
Contributor

Haroenv commented May 5, 2018

Hey @diegotham, I think I have a fix for this (#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!

@danduh
Copy link

danduh commented May 8, 2018

Same issue.

@0x6368656174
Copy link

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.

@Haroenv
Copy link
Contributor

Haroenv commented May 9, 2018

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 algolia/angular-instantsearch#90 (comment) in polyfill.ts:

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

@ArsalRaza
Copy link

I'm also getting the same issue

@trsh
Copy link

trsh commented May 24, 2018

Same here

@Haroenv
Copy link
Contributor

Haroenv commented May 24, 2018

Did you read the workaround @ArsalRaza @trsh ?

@vvo
Copy link

vvo commented May 25, 2018

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.

@algolia algolia locked as resolved and limited conversation to collaborators May 25, 2018
@Haroenv Haroenv closed this as completed Jun 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants