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 does not run after reinstalling node_modules #10

Open
dhythm opened this issue Jan 4, 2022 · 3 comments
Open

Blitz does not run after reinstalling node_modules #10

dhythm opened this issue Jan 4, 2022 · 3 comments

Comments

@dhythm
Copy link

dhythm commented Jan 4, 2022

What is the problem?

I create a new project by npx blitz new xxx, the node_modules has .blitz dir.
However, .blitz is gone after I delete node_modules and run npm install again.

Then, I catch an error below.

Thanks you for your kind help 🙏

Paste all your error logs here:

> blitz@0.44.4 postinstall /Users/y-okada/local/blitz-sample2/node_modules/blitz
> node scripts/postinstall.js

internal/modules/cjs/loader.js:883
  throw err;
  ^

Error: Cannot find module '.blitz'
Require stack:
- /Users/y-okada/local/blitz-sample2/node_modules/next/dist/stdlib/index.js
- /Users/y-okada/local/blitz-sample2/node_modules/next/stdlib.js
- /Users/y-okada/local/blitz-sample2/node_modules/blitz/dist/blitz.cjs.dev.js
- /Users/y-okada/local/blitz-sample2/node_modules/blitz/dist/blitz.cjs.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/Users/y-okada/local/blitz-sample2/node_modules/next/dist/stdlib/index.js:85:14)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/y-okada/local/blitz-sample2/node_modules/next/dist/stdlib/index.js',
    '/Users/y-okada/local/blitz-sample2/node_modules/next/stdlib.js',
    '/Users/y-okada/local/blitz-sample2/node_modules/blitz/dist/blitz.cjs.dev.js',
    '/Users/y-okada/local/blitz-sample2/node_modules/blitz/dist/blitz.cjs.js'
  ]
}

Paste all relevant code snippets here:

nothing to add after blitz new

What are detailed steps to reproduce this?

  1. npx blitz new blitz-sample2
  2. delete node_modules
  3. npm i

Run blitz -v and paste the output here:

Loaded env from /Users/y-okada/local/blitz-sample2/.env.local
Loaded env from /Users/y-okada/local/blitz-sample2/.env
macOS Catalina | darwin-x64 | Node: v14.15.4

blitz: 0.44.4 (local)

  Package manager: npm 
  System:
    OS: macOS 10.15.7
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 979.63 MB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 14.15.4 - ~/.anyenv/envs/nodenv/versions/14.15.4/bin/node
    Yarn: 1.22.11 - ~/.anyenv/envs/nodenv/versions/14.15.4/bin/yarn
    npm: 6.14.10 - ~/.anyenv/envs/nodenv/versions/14.15.4/bin/npm
    Watchman: 2021.06.07.00 - /usr/local/bin/watchman
  npmPackages:
    @prisma/client: 3.7.0 => 3.7.0 
    blitz: 0.44.4 => 0.44.4 
    prisma: 3.7.0 => 3.7.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.4 

Please include below any other applicable logs and screenshots that show your problem:

After running npm i again.
image

@beerose
Copy link
Contributor

beerose commented Jan 4, 2022

Hi @dhythm!

It does like an issue (reproduced it with npm), and the current workaround would be to run blitz codegen after npm install to generate the .blitz directory.

@dhythm
Copy link
Author

dhythm commented Jan 4, 2022

Hi @beerose !
Thanks for your comment!
I confirm .blitz is created via blitz codegen 👍

@beerose
Copy link
Contributor

beerose commented Jan 21, 2022

Observations:

  • Not sure where the error is coming from exactly. Everything is wrapped in try/catch in postinstall script.
  • It works sometimes.
  • ensureEmptyDotBlitz function seems to work without issues.
  • The key difference between a working script and a failing script is that the latter installs the next package manually: blitz:postinstall Missing next package, manually installing....

@dillondotzip dillondotzip transferred this issue from blitz-js/blitz Jul 7, 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

3 participants