vercel icon indicating copy to clipboard operation
vercel copied to clipboard

`vercel dev` not working with Gatsby project

Open leerob opened this issue 2 years ago • 2 comments

  1. Clone the Gatsby example locally

  2. Run yarn develop to correctly see the Gatsby index route. However, the date is wrong because we're not running the function. CleanShot 2022-01-17 at 21 36 55@2x

  3. Kill the dev server and instead run vercel dev

  4. With 23.1.2 (latest stable), we see NO_RESPONSE_FROM_FUNCTION displayed CleanShot 2022-01-17 at 21 39 02@2x

Accessing the API route directly shows a 404 CleanShot 2022-01-17 at 21 39 18@2x

  1. With 23.1.3-canary.72 (latest canary), it shows Cannot find module '/Users/leerob/Developer/vercel/node_modules/vercel-plugin-middleware/dist/index'. Please verify that the package.json has a valid "main" entry in the browser.

I realized this was only for Node 17 when looking at the stack trace:

Error: Cannot find module '/Users/leerob/Developer/vercel/node_modules/vercel-plugin-middleware/dist/index'. Please verify that the package.json has a valid "main" entry
    at tryPackage (node:internal/modules/cjs/loader:353:19)
    at Function.Module._findPath (node:internal/modules/cjs/loader:566:18)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
    at Function.resolve (node:internal/modules/cjs/helpers:108:19)
    at Object.loadCliPlugins (/Users/leerob/.nvm/versions/node/v17.1.0/lib/node_modules/vercel/dist/index.js:269839:34)
    at DevServer.runDevMiddleware (/Users/leerob/.nvm/versions/node/v17.1.0/lib/node_modules/vercel/dist/index.js:261137:46)
    at DevServer.serveProjectAsNowV2 (/Users/leerob/.nvm/versions/node/v17.1.0/lib/node_modules/vercel/dist/index.js:261205:38)
    at Server.DevServer.devServerHandler (/Users/leerob/.nvm/versions/node/v17.1.0/lib/node_modules/vercel/dist/index.js:261107:17) {
  code: 'MODULE_NOT_FOUND',
  path: '/Users/leerob/Developer/vercel/node_modules/vercel-plugin-middleware/package.json',
  requestPath: 'vercel-plugin-middleware'
}

Latest canary works with Node 16 ✅ But then latest stable throws this error...

Error: socket hang up
    at connResetException (internal/errors.js:639:14)
    at Socket.socketOnEnd (_http_client.js:499:23)
    at Socket.emit (events.js:412:35)
    at Socket.emit (domain.js:475:12)
    at endReadableNT (internal/streams/readable.js:1334:12)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)

It's also important to mention this example works correctly when deployed.

leerob avatar Jan 18 '22 03:01 leerob

I think this is related https://github.com/vercel/vercel/issues/7306

leerob avatar Jan 18 '22 04:01 leerob

Hey, @leerob. I think the easiest way to check if the issues are related is if you (temporarily) remove ::1 localhost from your hosts file and see if vc dev works correctly without it.

gadicc avatar Jan 18 '22 13:01 gadicc