bun icon indicating copy to clipboard operation
bun copied to clipboard

Node.js child_process compatibility

Open dylang opened this issue 3 years ago • 11 comments

Version

0.1.3

Platform

Darwin dgreene-mbp 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:22 PDT 2022; root:xnu-8020.121.3~4/RELEASE_X86_64 x86_64

What steps will reproduce the bug?

Repo case: https://codedamn.com/playground/--6R64znbeUkhqixLdUX_

If that doesn't work:

Make a file with just this one line:

require('child_process');

Save it as child.js.

bun run child.js

How often does it reproduce? Is there a required condition?

Just need to import child_process.

What is the expected behavior?

Child process loads.

What do you see instead?

Result:

error: Cannot find package "child_process" from "/Users/dylang/example/child.js"

Additional information

Note this is not the same error as when a module has not been installed or is an internal module not yet supported. That would look like this:

error: Could not resolve: "child_____process". Maybe you need to "bun install"?

dylang avatar Jul 11 '22 21:07 dylang

I don't believe bun supports child_process yet. See https://github.com/oven-sh/bun/issues/159

boehs avatar Jul 11 '22 21:07 boehs

Thanks @boehs, I missed that in my searching!

Maybe we can provide more friendly error messages for unimplemented node packages, such as

Bun has not yet implemented node's child_process package. You will need to disable code that uses this for now. Follow https://github.com/oven-sh/bun/issues/595 for progress on this feature.

dylang avatar Jul 11 '22 21:07 dylang

I landed upon this by running a Node.js script that uses Commander, and the Commander package prints this same error.

Commander is a very popular package for CLI tools.

robogeek avatar Jul 14 '22 16:07 robogeek

This seems to be an issue using jsdom also.

import * as jsdom from 'jsdom'

console.log(jsdom)

error: Cannot find package "child_process" from "/Users/thee/git-repo/bun-migrate/scraper/node_modules/jsdom/lib/jsdom/living/xhr/XMLHttpRequest-impl.js"

meepeek avatar Jul 15 '22 00:07 meepeek

How often does it reproduce? Is there a required condition?

Just need to import child_process.

If you need child_process now, you can use 3rd package like bun-utilities and after implementation you can use native module child_process

xhyrom avatar Jul 17 '22 06:07 xhyrom

I got this issue while using commander.js (Cannot use bun with commander..)

softmarshmallow avatar Jul 21 '22 19:07 softmarshmallow

I am working on this.

sno2 avatar Jul 28 '22 01:07 sno2

I am working on this.

How's your progress? 🙏

tomByrer avatar Aug 25 '22 06:08 tomByrer

@xHyroM might have to assign someone else to this please. Not having child_process is holding up MANY people from using Bun as they wish.

tomByrer avatar Aug 26 '22 05:08 tomByrer

How's your progress? 🙏

I already talked to Jarred about switching my progress to someone else because I have school now. Although, he has not replied yet. Now, there should be people getting paid to do this stuff, so you'll most likely see child_process soon.

sno2 avatar Aug 26 '22 11:08 sno2

@Jarred-Sumner Any update on child_process?

Re: https://twitter.com/jarredsumner/status/1579898972650381312

vjpr avatar Oct 27 '22 13:10 vjpr

#1424 👀

boehs avatar Nov 03 '22 03:11 boehs

This has been implemented as of Bun v0.3.0 🎉

Electroid avatar Dec 07 '22 20:12 Electroid