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

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

Open
codemile opened this issue Dec 5, 2021 · 2 comments
Open

Comments

@codemile
Copy link

codemile commented Dec 5, 2021

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
Copy link
Contributor

beerose commented Dec 8, 2021

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.

@beerose beerose changed the title Blitz throws unhandled error when run outside a project. Blitz throws unhandled error when run outside a project on Windows Dec 15, 2021
@paulbryan
Copy link

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

@beerose beerose transferred this issue from blitz-js/blitz Jul 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants