Skip to content

process is undefined in lib/internal/streams/pipeline.js #496

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

Closed
rybesh opened this issue Nov 14, 2022 · 8 comments · Fixed by #497
Closed

process is undefined in lib/internal/streams/pipeline.js #496

rybesh opened this issue Nov 14, 2022 · 8 comments · Fixed by #497

Comments

@rybesh
Copy link

rybesh commented Nov 14, 2022

I am using N3.js which recently upgraded readable-stream from 3.6.0 to 4.0.0. Now I can no longer build my project using browserify; I get the following error:

node_modules/.bin/browserify -d -o periodo-client.js modules/periodo-app/src/index.js
Error: Can't walk dependency graph: ENOENT: no such file or directory, lstat '/home/runner/work/periodo-tests/periodo-tests/periodo-client/process'
    required by /home/runner/work/periodo-tests/periodo-tests/periodo-client/node_modules/n3/node_modules/readable-stream/lib/internal/streams/pipeline.js
@mcollina
Copy link
Member

@rybesh
Copy link
Author

rybesh commented Nov 14, 2022

I'm not using Webpack 5, so I don't understand how that passage applies to my case.

@mcollina
Copy link
Member

cc @ShogunPanda

@vweevers
Copy link
Contributor

vweevers commented Nov 14, 2022

There are several issues here:

  1. Taking the Webpack 5 approach, instead of requiring bundlers to inject shims for node core modules (readable-stream v4 #439 (comment)). Meaning we now do require('process') instead of using a global:
    const process = require('process')
  2. This browserify bug that breaks require('process'): Error: Can't walk dependency graph if a dependency has the same name like node builtin browserify/browserify#1986
  3. This workaround that assumes the process package always lives at ./node_modules/process (i.e. that it's not hoisted):
    module.exports = require('./node_modules/process')
  4. The files declaration in package.json that's missing the process file:
    "files": [
    "lib",
    "LICENSE",
    "README.md"
    ],

@vweevers
Copy link
Contributor

@ShogunPanda When you worked on this, did you try require('process/') instead of require('process')? If that works (for all bundlers) then we don't need the workaround.

@bergos
Copy link
Contributor

bergos commented Nov 15, 2022

It looks like the workaround with require('process/') would work on Node.js and all bundlers.

I didn't use the workaround because I wanted to keep the Node.js behavior to directly load the internal process module. But it looks like the process-shim doesn't contain much logic, so I guess it would be ok to have this one additional require.

@vweevers
Copy link
Contributor

@bergos Ah, I see now that it's your code (#489) rather than @ShogunPanda's. Sorry, I missed that PR. Side note: if bundler configuration is no longer required, then Usage In Browsers is outdated.

I'm not a fan of the general approach, but in the interest of moving forward, I vote for require('process/') too.

@mcollina
Copy link
Member

I'm ok in adding the process-shim.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants