blitz-js / legacy-framework

MIT License
3 stars 2 forks source link

Blitz throws unhandled error when run outside a project on Windows #991

Open codemile opened 2 years ago

codemile commented 2 years ago

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

beerose commented 2 years ago

That's odd. It should print the following message:

~/workspace/random-dir blitz
 ›   Error: You are not inside a Blitz project, so this command won't work.
 ›   You can create a new app with blitz new myapp or see help with blitz help

We'll investigate why it throws an error instead.

paulbryan commented 2 years ago

I get the same error when running blitz --help outside a project folder. blitz -h does work though!?