blitz
blitz copied to clipboard
blitz codegen commands cause errors if there are parenthesis in path
What is the problem?
The blitz new app generation encounters an error when trying to generate app/auth/components/LoginForm.tsx. Due to this error, I cannot create a new Blitz app.
Paste all your error logs here:
✕ Error generating app/auth/components/LoginForm.tsx
SyntaxError: Unexpected token, expected ")" (26:24)
Paste all relevant code snippets here:
$ node -v
v17.0.1
$ yarn -v
1.22.11
What are detailed steps to reproduce this?
blitz new simpleActivityTracker- Install dependencies (either
via npm,via yarn, orskiphas no impact on the bug) - Pick a form library (you can switch to something else later if you want) (either
React Final Form (recommended),React Hook Form, orFormikhas no impact on the bug) - Receive the following error
✕ Error generating app/auth/components/LoginForm.tsx
SyntaxError: Unexpected token, expected ")" (26:24)
Run blitz -v and paste the output here:
macOS Big Sur | darwin-x64 | Node: v17.0.1
blitz: 0.41.1 (global)
Package manager: npm
System:
OS: macOS 11.6
CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
Memory: 564.47 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 17.0.1 - ~/.nvm/versions/node/v17.0.1/bin/node
Yarn: 1.22.11 - /usr/local/bin/yarn
npm: 8.1.0 - ~/.nvm/versions/node/v17.0.1/bin/npm
Watchman: Not Found
npmPackages:
@prisma/client: Not Found
blitz: Not Found
prisma: Not Found
react: Not Found
react-dom: Not Found
typescript: Not Found
Please include below any other applicable logs and screenshots that show your problem:
No response
Can you try node v16? Looks like there could be a Node v17 issue
Still occurs with node v16.
I am not able to reproduce on v16.6.1
My guess would be that there can be a babel plugin that interferes and that causes a parsing issue.
Could you try to run blitz new in different locations?
Still occurs with node v16.
me too
UPDATE: when I updated to Blitz 0.42.0, it gave me a new option to choose Full - includes DB and auth (Recommended) vs. Minimal — no DB, no auth. The above-described error happens when I choose the Full option. But it does not happen when I choose the Minimal option. Choice of other blitz new setup options seems to have no effect on this bug either way.
Which directory I am running blitz new in also seems to have no effect.
We are unable to reproduce this. It appears to be environment-specific. It would be ideal if someone who can reproduce it, could work on it. In the meantime, you could try a different terminal, or run npx blitz new ....
It works when removing blitz from global dependancies, and using npx blitz new ....
Okay, then maybe that's a global installation issue? Did you try reinstalling Blitz? Also, another thing to check is if it helps if you switch to node 14.
I am already on node 14, and I encountered the error while I'm on node 14.
but after I removed blitz from global dependencies and used npx it worked.
I ran into the same issue with:
macOS Catalina | darwin-x64 | Node: v14.17.5
blitz: 0.44.3 (global) blitz: 0.44.3 (local)
Package manager: npm System: OS: macOS 10.15.7 CPU: (8) x64 Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz Memory: 1.27 GB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 14.17.5 - ~/.nvm/versions/node/v14.17.5/bin/node Yarn: 1.13.0 - /usr/local/bin/yarn npm: 6.14.11 - ~/.npm-packages/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman npmPackages: @prisma/client: 3.6.0 => 3.6.0 blitz: 0.44.3 => 0.44.3 prisma: 3.6.0 => 3.6.0 react: 18.0.0-beta-149b420f6-20211119 => 18.0.0-beta-149b420f6-20211119 react-dom: 18.0.0-alpha-5ca4b0433-20211020 => 18.0.0-alpha-5ca4b0433-20211020 typescript: ~4.5 => 4.5.2
I figured out it happens if your current path has parenthesis in it. If you change the folder names to not use parenthesis, it works. Must be something wrong in the way blitz parses the current path.
Seems to be true of pretty much all blitz commands that install something, they have issues if your path has parenthesis, at least on a Mac.
Note: it might have something to do with mem-fs-editor that Blitz uses
Kind of narrowed it down a little.
Running via npx blitz new test works just fine. But following the getting started instructions and installing globally via yarn with yarn global add blitz and blitz new test fails for me. This is all on node 16.
Same issue here after following the doc with "yarn global add blitz"
blitz -v Blitz version: 2.0.0-beta.4 (global) macOS Monterey | darwin-x64 | Node: v17.8.0
Package manager: npm
System: OS: macOS 12.6 CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz Memory: 754.93 MB / 16.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 17.8.0 - ~/.nvm/versions/node/v17.8.0/bin/node Yarn: 1.22.5 - ~/.yarn/bin/yarn npm: 8.6.0 - ~/.nvm/versions/node/v17.8.0/bin/npm npmPackages: @blitzjs/auth: Not Found @blitzjs/next: Not Found @blitzjs/rpc: Not Found @prisma/client: Not Found blitz: Not Found next: Not Found prisma: Not Found react: Not Found react-dom: Not Found typescript: Not Found
Workaround:
yarn global remove blitz npx blitz new test Select options => works fine