Angular 6 - process is not defined when trying to serve application Angular 6 - process is not defined when trying to serve application javascript javascript

Angular 6 - process is not defined when trying to serve application


In polyfill.ts, add this line:

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

Reference: https://github.com/algolia/algoliasearch-client-javascript/issues/691


Or npm i -S process, then add this to polyfill.ts:

import * as process from 'process';window['process'] = process;


To fix the problem, I added the following lines to 'polyfills.ts' file,

(window as any).global = window;global.Buffer = global.Buffer || require('buffer').Buffer;global.process = require('process');


This is an incompatibility with Angular v6. They removed support (shim) of process and global variables in browser.

I suggest you to use Angular 5, till cosmic.js fixes the error. Maybe you can even open an issue for it.