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

Tutorial with React doesn't work #1136

Open
wjl opened this issue Feb 17, 2023 · 2 comments
Open

Tutorial with React doesn't work #1136

wjl opened this issue Feb 17, 2023 · 2 comments

Comments

@wjl
Copy link

wjl commented Feb 17, 2023

I tried following the tutorial here, using the React version: https://boardgame.io/documentation/#/tutorial

The first part which has you run these commands works fine:

npx create-react-app bgio-tutorial
cd bgio-tutorial
npm install boardgame.io
touch src/Game.js

If at this point you do an "npm start" you get a normal React app placeholder launched in the browser and everything seems okay.

However, the next step in the tutorial replaces src/App.js . After doing this and running "npm start", I get this error:

Error in ./~/boardgame.io/dist/cjs/react.js
Module parse failed: /home/wjl/work/boardgame.io-tutorial/bgio-tutorial/node_modules/boardgame.io/dist/cjs/react.js Unexpected token (118:24)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (118:24)
 @ ./src/App.js 7:13-42

I've used both Nodejs and React for a few small projects, but I'm by no means fluent with them. But the "cjs" caught my eye and after some searching on the web I played around with some advice there, installed the esm module, changed index.js to force esm use, and eventually kind of got it to launch, but at that point it had other problems (the boardgame.io debug interface ran but wouldn't update game state) and still couldn't finish the tutorial.

For background this was done on an Ubuntu 22.04.01 LTS system using the nodejs snap. (The nodejs deb package is too old to work with React.) Node version is:

node --version
v18.13.0

Anyway, I'm going to try the tutorial again without React, but I wanted to let you know that the tutorial, at least for me, appears to be broken. My best guess is that something changed with React or with some other dependency, and it's probably an easy fix for someone who knows what they are doing. =)

@wjl
Copy link
Author

wjl commented Feb 17, 2023

Just to follow up, I did the tutorial with plain js and it worked fine.

@wjl
Copy link
Author

wjl commented Feb 17, 2023

If it helps, here are the package.json and package-lock.json generated by running the tutorial commands (the only difference in this case was I used a different folder name, "tictactoe-react" so I didn't clobber the plainjs version I just tried). I didn't manually edit these files at all.

package.json.zip
package-lock.json.zip

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

No branches or pull requests

1 participant