blitz-js / legacy-framework

MIT License
2 stars 2 forks source link

Cannot find module '.blitz' when deploying to Vercel #162

Closed jp3isme closed 2 years ago

jp3isme commented 2 years ago

What is the problem?

After trying to deploy a project to vercel I've been working on with no success, I tried deploying a fresh Blitz app and still had issues.

Paste all your error logs here:

> blitz@0.45.0 postinstall /opt/render/project/src/node_modules/blitz
> node scripts/postinstall.js
 internal/modules/cjs/loader.js:905
    throw err;
    ^

Error: Cannot find module '.blitz'
Require stack:
- /vercel/path0/node_modules/next/dist/stdlib/index.js
- /vercel/path0/node_modules/next/stdlib.js
- /vercel/path0/node_modules/blitz/dist/blitz.cjs.dev.js
- /vercel/path0/node_modules/blitz/dist/blitz.cjs.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:93:18)
    at Object.<anonymous> (/vercel/path0/node_modules/next/dist/stdlib/index.js:85:14)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/vercel/path0/node_modules/next/dist/stdlib/index.js',
    '/vercel/path0/node_modules/next/stdlib.js',
    '/vercel/path0/node_modules/blitz/dist/blitz.cjs.dev.js',
    '/vercel/path0/node_modules/blitz/dist/blitz.cjs.js'
  ]
}

Paste all relevant code snippets here:

N/A

What are detailed steps to reproduce this?

  1. blitz new
  2. ✔ Pick a new project's language · TypeScript
  3. ✔ Pick your new app template · full
  4. ✔ Install dependencies? (Y/n) · true
  5. ✔ Pick a form library (you can switch to something else later if you want) · React Hook Form
  6. push to github repo
  7. link Vercel project to github repo
  8. build fails on Vercel

Run blitz -v and paste the output here:

On my local machine:

macOS Big Sur | darwin-x64 | Node: v14.15.5

blitz: 0.45.1 (global)
blitz: 0.45.1 (local)

  Package manager: npm 
  System:
    OS: macOS 11.0
    CPU: (4) x64 Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
    Memory: 21.27 MB / 8.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 14.15.5 - /usr/local/bin/node
    Yarn: Not Found
    npm: 6.14.11 - /usr/local/bin/npm
    Watchman: Not Found
  npmPackages:
    @prisma/client: 3.8.1 => 3.8.1 
    blitz: 0.45.1 => 0.45.1 
    prisma: 3.8.1 => 3.8.1 
    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:

No response

jp3isme commented 2 years ago

I managed to get it deployed on Render with this render.yaml (I'm using a mongoDB db on atlas):

services:
  - type: web
    name: appname
    env: node
    plan: starter
    buildCommand: yarn --frozen-lockfile --prod=false &&
      blitz prisma generate &&
      blitz build
    startCommand: blitz start
    envVars:
      - key: NODE_ENV
        value: production

But I'm still curious about understanding this issue and getting it working on vercel

beerose commented 2 years ago

Thanks for reporting it @jp3isme — we'll try to investigate it soon.

beerose commented 2 years ago

@jp3isme Could you provide more build logs?


Possibly related: https://github.com/blitz-js/legacy-framework/issues/10

jp3isme commented 2 years ago

Unfortunately, I'll have to attach images, I hope that's ok. Either Vercel doesn't let you export logs or I just can't find how, and it will only let me copy and paste one line at a time.

This is the output for the fresh blitz app

Screen Shot 2022-01-22 at 1 14 49 AM Screen Shot 2022-01-22 at 1 15 03 AM Screen Shot 2022-01-22 at 1 15 13 AM Screen Shot 2022-01-22 at 1 15 20 AM
beerose commented 2 years ago

Hey, I apologize for the late reply and for this issue.

I was able to narrow the issue down to these lines: https://github.com/blitz-js/blitz/blob/canary/packages/blitz/scripts/postinstall.js#L125-L133. It seems that if we install next manually, the .blitz directory can't be found.

This is something that we think will go away with the new toolkit, but in the meantime, I'd try using yarn instead of npm.

beerose commented 2 years ago

Closing due to inactivity.