question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"process is not defined" FIX causes "Cannot read property 'Stream' of undefined"

See original GitHub issue

Describe the bug Importing and adding my ApiService to a component constructor (angular) causes the following error:

Uncaught ReferenceError: process is not defined
    at Module../node_modules/graphql/module/jsutils/instanceOf.js (instanceOf.js:3)
    at __webpack_require__ (bootstrap:78)
    at Module../node_modules/graphql/module/type/definition.js (definition.js:1)
    at __webpack_require__ (bootstrap:78)
    at Module../node_modules/graphql/module/type/validate.js (validate.js:1)
    at __webpack_require__ (bootstrap:78)
    at Module../node_modules/graphql/module/graphql.js (graphql.js:1)
    at __webpack_require__ (bootstrap:78)
    at Module../node_modules/graphql/module/index.js (vendor.js:188197)
    at __webpack_require__ (bootstrap:78)

I can fix this by adding the following to polyfills:

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

However, doing so causes the following error when authenticating:

Cannot read property 'Stream' of undefined ; Zone: <root> ; Task: Promise.then ; Value: TypeError: Cannot read property 'Stream' of undefined
    at Object.computeSha256 (util.js:705)
    at Request.COMPUTE_SHA256 (event_listeners.js:142)
    at Request.callListeners (sequential_executor.js:105)
    at Request.emit (sequential_executor.js:81)
    at Request.emit (request.js:683)
    at Request.transition (request.js:22)
    at AcceptorStateMachine.runTo (state_machine.js:14)
    at state_machine.js:26
    at Request.<anonymous> (request.js:38)
    at Request.<anonymous> (request.js:685) TypeError: Cannot read property 'Stream' of undefined
    at Object.computeSha256 (http://localhost:4200/vendor.js:175140:32)
    at Request.COMPUTE_SHA256 (http://localhost:4200/vendor.js:166545:18)
    at Request.callListeners (http://localhost:4200/vendor.js:171389:18)
    at Request.emit (http://localhost:4200/vendor.js:171365:10)
    at Request.emit (http://localhost:4200/vendor.js:169999:14)
    at Request.transition (http://localhost:4200/vendor.js:169338:10)
    at AcceptorStateMachine.runTo (http://localhost:4200/vendor.js:174393:12)
    at http://localhost:4200/vendor.js:174405:10
    at Request.<anonymous> (http://localhost:4200/vendor.js:169354:9)
    at Request.<anonymous> (http://localhost:4200/vendor.js:170001:12)

I’ve narrowed it down to that. I can get rid of one error, by adding the polyfill, and get rid of the other error by removing the polyfill.

I’ve got no idea why the .process polyfill would be causing Cannot read property 'Stream' of undefined. Doesn’t make any sense to me.

This is breaking my application though, and I can’t get around it.

There seems to be so many bugs with amplify. Sigh… it was a nice dream.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

9reactions
gerrytsuicommented, May 31, 2019

Duplicate of #3193

I found a way to properly Polyfill the “process is not defined”

npm install -S process

the add the following to your polyfills.ts

import * as process from ‘process’; window[‘process’] = process;

and set tsconfig.json

“target”: “es2015”,

1reaction
EmanHcommented, May 19, 2019

Again, I was able to delete the component, and re-create a new component. Copy and paste the same code, and the error didn’t occur. I’m not sure what causes it, but re-creating the component is (an inconvenient) work-around for now.

Then a couple of hours later, creating a brand new component, import the APIService and it’s back. 😦

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - Uncaught ReferenceError: process is not defined
I am using the command "npm start" which refers to the "start" script inside package.json that is set to "start": "http-server -a localhost...
Read more >
ReferenceError: “process is not defined” - GIMTEC
In NodeJS, “process” is defined, but not in the browser. This is because NodeJS and the browser are different runtime environments. Common Error....
Read more >
Stream | Node.js v19.3.0 Documentation
The 'unpipe' event is emitted when the stream.unpipe() method is called on a Readable stream, removing this Writable from its set of destinations....
Read more >
Error in test-mode on 1.3 (TypeError: Cannot read property ...
I am using the aws-sdk in the meteor-app and that is working without any problems. When I start the new test-mode from Meteor...
Read more >
Cannot read properties of undefined (reading 'length') - TrackJS
This error can be thrown for a lot of reasons, as it is incredibly common to reference the length property of string or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found