`netlify dev` results in "Could not find function 'next-dev'"

When I run netlify dev, it doesn’t work and I get this error:

Error - Could not find function 'next-dev'

Here is the error from the console:

◈ Failed to run Edge Function next-dev:
TypeError: Module not found "file:///C:/Users/Administrator/Next.js/gobetterway/.netlify/edge-functions/vendor/esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/request.js".
    at file:///C:/Users/Administrator/Next.js/gobetterway/.netlify/edge-functions/next-dev/index.js:1:29
    at async file:///C:/Users/Administrator/Next.js/gobetterway/.netlify/edge-functions-serve/dev.js:7:35 {
  code: "ERR_MODULE_NOT_FOUND"
}
TypeError: Module not found "file:///C:/Users/Administrator/Next.js/gobetterway/.netlify/edge-functions/vendor/esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/request.js".
    at file:///C:/Users/Administrator/Next.js/gobetterway/.netlify/edge-functions/next-dev/index.js:1:29
    at async file:///C:/Users/Administrator/AppData/Roaming/npm/node_modules/netlify-cli/node_modules/@netlify/edge-bundler/deno/config.ts:12:10 {
  code: "ERR_MODULE_NOT_FOUND"
}

When I checked the .netlify/edge-functions folder, the vendor folder doesn’t even exist.

I am on WIndows 10 64bit. It’s a NextJS project.

I have installed deno on my systems already…

1 Like

Update:

I do not encounter this error when I run netlify dev from an Administrator cmd window.

But now I get this error:

◈ Netlify Dev ◈
◈ No app server detected. Using simple static server
◈ Unable to determine public folder to serve files from. Using current working directory
◈ Setup a netlify.toml file with a [dev] section to specify your dev server settings.
◈ See docs at: https://cli.netlify.com/netlify-dev#project-detection
◈ Running static server from "Next.js"
◈ Setting up local development server

◈ Static server listening to 3999

And a 404 not found at localhost:8888

Nevermind, I’m a dummy. I was running the elevated cmd in the wrong folder.

Running netlify dev in the elevated cmd window inside my project folder gives the same error as the top:

Here is the full output:

Netlify Dev ◈
◈ Setting up local development server
◈ Starting Netlify Dev with custom config
√ Waiting for framework port 3000. This can be configured using the 'targetPort' property in the netlify.toml

   ┌─────────────────────────────────────────────────┐
   │                                                 │
   │   ◈ Server now ready on http://localhost:8888   │
   │                                                 │
   └─────────────────────────────────────────────────┘

◈ Loaded edge function netlify dev handler
◈ Loaded function getServices
◈ Failed to run Edge Function next-dev:
TypeError: Module not found "file:///C:/Users/Administrator/Next.js/gobetterway/.netlify/edge-functions/vendor/esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/request.js".
    at file:///C:/Users/Administrator/Next.js/gobetterway/.netlify/edge-functions/next-dev/index.js:1:29
    at async file:///C:/Users/Administrator/Next.js/gobetterway/.netlify/edge-functions-serve/dev.js:7:35 {
  code: "ERR_MODULE_NOT_FOUND"
}
TypeError: Module not found "file:///C:/Users/Administrator/Next.js/gobetterway/.netlify/edge-functions/vendor/esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/request.js".
    at file:///C:/Users/Administrator/Next.js/gobetterway/.netlify/edge-functions/next-dev/index.js:1:29
    at async file:///C:/Users/Administrator/AppData/Roaming/npm/node_modules/netlify-cli/node_modules/@netlify/edge-bundler/deno/config.ts:12:10 {
  code: "ERR_MODULE_NOT_FOUND"
}
  ▲ Next.js 13.5.4
  - Local:        http://localhost:3000
  - Environments: .env

 ✓ Ready in 2.3s
◈ Reloading edge functions...
◈ Failed to run Edge Function next-dev:
TypeError: Module not found "file:///C:/Users/Administrator/Next.js/gobetterway/.netlify/edge-functions/vendor/esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/request.js".
    at file:///C:/Users/Administrator/Next.js/gobetterway/.netlify/edge-functions/next-dev/index.js:1:29
    at async file:///C:/Users/Administrator/Next.js/gobetterway/.netlify/edge-functions-serve/dev.js:7:35 {
  code: "ERR_MODULE_NOT_FOUND"
}
TypeError: Module not found "file:///C:/Users/Administrator/Next.js/gobetterway/.netlify/edge-functions/vendor/esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/request.js".
    at file:///C:/Users/Administrator/Next.js/gobetterway/.netlify/edge-functions/next-dev/index.js:1:29
    at async file:///C:/Users/Administrator/AppData/Roaming/npm/node_modules/netlify-cli/node_modules/@netlify/edge-bundler/deno/config.ts:12:10 {
  code: "ERR_MODULE_NOT_FOUND"
}
◈ Failed reloading edge function
◈ Reloading edge functions...
◈ Failed to run Edge Function next-dev:
TypeError: Module not found "file:///C:/Users/Administrator/Next.js/gobetterway/.netlify/edge-functions/vendor/esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/request.js".
    at file:///C:/Users/Administrator/Next.js/gobetterway/.netlify/edge-functions/next-dev/index.js:1:29
    at async file:///C:/Users/Administrator/Next.js/gobetterway/.netlify/edge-functions-serve/dev.js:7:35 {
  code: "ERR_MODULE_NOT_FOUND"
}
TypeError: Module not found "file:///C:/Users/Administrator/Next.js/gobetterway/.netlify/edge-functions/vendor/esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/request.js".
    at file:///C:/Users/Administrator/Next.js/gobetterway/.netlify/edge-functions/next-dev/index.js:1:29
    at async file:///C:/Users/Administrator/AppData/Roaming/npm/node_modules/netlify-cli/node_modules/@netlify/edge-bundler/deno/config.ts:12:10 {
  code: "ERR_MODULE_NOT_FOUND"
}
◈ Failed reloading edge function

Here is netlify.toml:

[build]
  command = "next build"
  publish = ".next"

[functions]
  included_files = ["src/data/services/**"]

[[plugins]]
  package = "@netlify/plugin-nextjs"

[dev]
  command = "npm run dev"
  targetPort = 3000
  port = 8888
  framekwork = "next"

I have tried command = "npm run dev" and command = "next dev" and also having no [dev] config.

I have tried clearnig npm cache, deleting .netlify, node_modules, and .next and redoing npm install. I have tried with my site linked and unlinked.

Please help me lol

Please share a minimal reproduction that we can check on our end.

Thank you for getting back to me, but I found the problem. I had "@netlify/plugin-nextjs": "^4.40.2", under my dependencies in my package.json.

I removed it, ran npm i and then netlify dev worked.

Hope this helps someone else!

oh awesome! thanks for sharing this with the community.

I am having this same issue but didn’t have that in my package.json, did you make any other change to get this to work?

1 Like

I checked all my netlify sites, all are having this issue now in my local environment.

3 Likes

I have the same issue “Failed to run Edge Function next-dev:” in my local environment. If it’s useful additional info:

  • I upgraded the netlify CLI to see if that would resolve the error, no luck
  • I do not have @netlify/plugin-nextjs referenced in package.json
1 Like

Sorry to hear about the trouble, y’all! I’ve raised this issue with our dev team and they are looking into it for us.

2 Likes

Strange, it was working for me this morning… Havn’t touched it since, came back just now, and have the error again :S

1 Like

FYI, here is the stack trace which I don’t believe I have posted yet:

Error: Could not find function 'next-dev'
    at FunctionChain.getFunction (https://650bfd807b21ed000893e25c--edge.netlify.com/bootstrap/function_chain.ts:255:13)
    at FunctionChain.runFunction (https://650bfd807b21ed000893e25c--edge.netlify.com/bootstrap/function_chain.ts:346:23)
    at FunctionChain.run (https://650bfd807b21ed000893e25c--edge.netlify.com/bootstrap/function_chain.ts:316:31)
    at handleRequest (https://650bfd807b21ed000893e25c--edge.netlify.com/bootstrap/handler.ts:117:34)
    at Server. (https://650bfd807b21ed000893e25c--edge.netlify.com/bootstrap/server.ts:42:7)
    at Server.#respond (https://deno.land/std@0.170.0/http/server.ts:299:37)
    at Server.#serveHttp (https://deno.land/std@0.170.0/http/server.ts:346:20)
    at eventLoopTick (ext:core/01_core.js:183:11)
3 Likes

I also started seeing this later this afternoon (earlier this morning was working fine)
Only local development seems to be impacted, preview builds seem ok

1 Like

This started happening to us this morning and is still happening now. Netlify Support could we please get an update on this issue?

1 Like

Hi Netlify Support, really looking for an answer here. It’s stopping our development on local.

1 Like

Worked around this for now by adding the plugin to package.json and downgrading to 4.40.1: “@netlify/plugin-nextjs”: “4.40.1”,

3 Likes

Just adding that as of yesterday evening I had this issue. No code changes / updates, ‘netlify dev’ just stopped working. I didn’t have @netlify/plugin-nextjs in my package.json

I can confirm that @aaronupwell workaround fixed it for me temporarily.

2 Likes

Hi thank you all for writing in about this our team has actioned this.

1 Like

@SamO - just FYI - also not working for me as of yesterday afternoon or so.

I used to have this issue before as well but updating fixed it. I am having the same issue again, just like everyone else. I hope this gets fixed soon as local testing isn’t available.

1 Like