blitz-js / blitz-js/legacy-framework
Blitz throws unhandled error when run outside a project on Windows
- Dominant language
- JavaScript
- Stars
- 3
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
### What is the problem?
Blitz should be more friendly when run outside a blitz project without arguments.
When running the CLI outside a blitz project an unhandled error is thrown internally. Instead the CLI should provide the user with helpful feedback. Like a list of command arguments or version information. Instead it just seems to crash.
The expected behavior would be that it yields the same output as running `blitz` inside a project directory, but instead reports in a friendly way that it's not a blitz project. You should still see the version and available commands.
### Paste all your error logs here:
```
$ blitz
C:\Users\nick\AppData\Roaming\npm\node_modules\blitz\node_modules\next\dist\server\lib\utils.js:65
throw new Error('Unable to find project root by looking for your package.json or for ' + _constants.CONFIG_FILE);
^
Error: Unable to find project root by looking for your package.json or for .blitz.config.compiled.js
at getProjectRoot (...\blitz\node_modules\next\dist\server\lib\utils.js:65:15)
```
### Paste all relevant code snippets here:
```
```
### What are detailed steps to reproduce this?
1. run "blitz" in an empty folder.
### Run `blitz -v` and paste the output here:
```
$ blitz -v
Windows 10 | win32-x64 | Node: v16.13.0
blitz: 0.44.0 (global)
Package manager: npm
System:
OS: Windows 10 10.0.22000
CPU: (32) x64 AMD Ryzen 9 3950X 16-Core Processor
Memory: 45.35 GB / 63.92 GB
Binaries:
Node: 16.13.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.10 - ~\AppData\Roaming\npm\yarn.CMD
npm: 7.6.0 - ~\AppData\Roaming\npm\npm.CMD
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_
Contributor guide
Research direction
Reproduce the issue by running `blitz` in an empty folder, then trace the CLI path that invokes `getProjectRoot` from the reported Next.js error. Done means the command no longer throws an unhandled error and instead shows friendly feedback with the version and available commands, matching the behavior described in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100