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

Create react-app using --bun is broken #17236

Open
iot-imahmood opened this issue Feb 10, 2025 · 3 comments · May be fixed by #17251
Open

Create react-app using --bun is broken #17236

iot-imahmood opened this issue Feb 10, 2025 · 3 comments · May be fixed by #17251
Labels
bug Something isn't working

Comments

@iot-imahmood
Copy link

What version of Bun is running?

1.2.0

What platform is your computer?

Darwin 24.3.0 arm64 arm

What steps can reproduce the bug?

  1. Install bun globally
  2. Run: bun --bun create react-app my-react-app on terminal
  3. Errors and doesn't create anything inside the directory (my-react-app) except package-lock.json

What is the expected behavior?

  • Should work, without errors
  • Should generate all the necessary files
  • Should install all dependencies with its latest stable versions (e.g. react 19) using bun

What do you see instead?

Currently outputs:

Creating a new React app in <pwd>/react-app-19-bun-cli.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...

⠏
added 1326 packages in 19s

268 packages are looking for funding
  run `npm fund` for details
1 | 
2 |         const init = require('react-scripts/scripts/init.js');
3 |         init.apply(null, JSON.parse(process.argv[1]));
                                  ^
SyntaxError: JSON Parse error: Unrecognized token '/'
      at <pwd>/react-app-19-bun-cli/[eval]:3:31

Bun v1.2.0 (macOS arm64)

Aborting installation.
  node  has failed.

Deleting generated file... node_modules
Deleting generated file... package.json
Done.

Additional information

Currently next-app is working fine with bun. Below is an output from my machine.

❯ bun --bun create next-app next-app-bun-app-with-bun-cli 
✔ Would you like to use TypeScript? … No / Yes
✔ Would you like to use ESLint? … No / Yes
✔ Would you like to use Tailwind CSS? … No / Yes
✔ Would you like your code inside a `src/` directory? … No / Yes
✔ Would you like to use App Router? (recommended) … No / Yes
✔ Would you like to use Turbopack for `next dev`? … No / Yes
✔ Would you like to customize the import alias (`@/*` by default)? … No / Yes
Creating a new Next.js app in <pwd>/next-app-bun-app-with-bun-cli.

Using bun.

Initializing project with template: app-tw 


Installing dependencies:
- react
- react-dom
- next

Installing devDependencies:
- typescript
- @types/node
- @types/react
- @types/react-dom
- postcss
- tailwindcss
- eslint
- eslint-config-next
- @eslint/eslintrc

bun install v1.2.0 (b0c5a765)

+ @eslint/eslintrc@3.2.0
+ @types/node@20.17.17 (v22.13.1 available)
+ @types/react@19.0.8
+ @types/react-dom@19.0.3
+ eslint@9.20.0
+ eslint-config-next@15.1.6
+ postcss@8.5.1
+ tailwindcss@3.4.17 (v4.0.6 available)
+ typescript@5.7.3
+ next@15.1.6
+ react@19.0.0
+ react-dom@19.0.0

360 packages installed [2.52s]
Initialized a git repository.

Success! Created next-app-bun-app-with-bun-cli at <pwd>/next-app-bun-app-with-bun-cli
@iot-imahmood iot-imahmood added bug Something isn't working needs triage labels Feb 10, 2025
@reillyjodonnell
Copy link

darwin 24.2 arm64 w/ bun 1.2.2

reilly@mac trash % bun --bun create react-app my-react-app

Creating a new React app in /Users/reilly/programming/forks/bun/trash/my-react-app.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...


added 1326 packages in 20s

268 packages are looking for funding
  run `npm fund` for details
1 | 
2 |         const init = require('react-scripts/scripts/init.js');
3 |         init.apply(null, JSON.parse(process.argv[1]));
                                  ^
SyntaxError: JSON Parse error: Unrecognized token '/'
      at /Users/reilly/programming/forks/bun/trash/my-react-app/[eval]:3:31

@kravetsone

This comment has been minimized.

@RiskyMH
Copy link
Member

RiskyMH commented Feb 11, 2025

the root cause of this issue is #12209 because its overwriting the first argument with the "path", the node exec (bun in this case) now doesn't have the ability to read it.

https://github.com/facebook/create-react-app/blob/b532a58792ea79ba7b0e85c1cb42b2a36dafe276/packages/create-react-app/createReactApp.js#L524

# node  -p "process.argv" a
[ '/root/.nvm/versions/node/v23.6.1/bin/node', 'a' ]

# bun  -p "process.argv" a
[ "/root/.bun/bin/bun", "/root/[eval]" ]

also in current state create-react-app isn't working as its calling npm to install and there are lots of react@19 peer deps errors.

@RiskyMH RiskyMH linked a pull request Feb 11, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants