Error finding node_modules when building

snazzy-scone-e085a1

2:18:37 PM: $ npm run dev

2:18:37 PM: > jimandhelen@0.1.0 dev /opt/build/repo

2:18:37 PM: > next dev

2:18:38 PM: ready - started server on 0.0.0.0:3000, url: http://localhost:3000

2:18:41 PM: event - compiled client and server successfully in 2.9s (576 modules)

2:53:51 PM: wait - compiling…

2:53:51 PM: Build exceeded maximum allowed runtime

2:53:51 PM: event - compiled client and server successfully in 235 ms (136 modules)

2:53:51 PM: > Found a change in next.config.js. Restart the server to see the changes in effect.

2:53:51 PM: wait - compiling…

2:53:51 PM: error - ./node_modules/scheduler/index.js

2:53:51 PM: Module build failed: Error: ENOENT: no such file or directory, open ‘/opt/build/repo/node_modules/scheduler/index.js’

2:53:52 PM: wait - compiling…

2:53:52 PM: event - compiled successfully in 47 ms (21 modules)

2:53:52 PM: wait - compiling…

2:53:52 PM: error - Module not found: Error: Can’t resolve ‘./node_modules/next/dist/client/dev/amp-dev’ in ‘/opt/build/repo’
wait - compiling…

2:54:52 PM: error - Module not found: Error: Can’t resolve ‘private-next-pages/_app’ in ‘/opt/build/repo’
error - unhandledRejection: [Error: ENOENT: no such file or directory, stat ‘/opt/build/repo/.next/cache/webpack/client-development/0.pack’] {

2:54:52 PM: errno: -2,

2:54:52 PM: code: ‘ENOENT’,

2:54:52 PM: syscall: ‘stat’,

2:54:52 PM: path: ‘/opt/build/repo/.next/cache/webpack/client-development/0.pack’

2:54:52 PM: }

2:54:52 PM: [webpack.cache.PackFileCacheStrategy] Caching failed for pack: Error: ENOENT: no such file or directory, stat ‘/opt/build/repo/.next/cache/webpack/client-development/0.pack’

2:54:52 PM: (node:1827) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)

2:54:52 PM: (Use node --trace-warnings ... to show where the warning was created)

2:54:52 PM: error - unhandledRejection: [Error: ENOENT: no such file or directory, stat ‘/opt/build/repo/.next/cache/webpack/server-development/0.pack’] {

2:54:52 PM: errno: -2,

2:54:52 PM: code: ‘ENOENT’,

2:54:52 PM: syscall: ‘stat’,

2:54:52 PM: path: ‘/opt/build/repo/.next/cache/webpack/server-development/0.pack’

2:54:52 PM: }

2:54:52 PM: [webpack.cache.PackFileCacheStrategy] Caching failed for pack: Error: ENOENT: no such file or directory, stat ‘/opt/build/repo/.next/cache/webpack/server-development/0.pack’

2:54:52 PM: (node:1827) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 2)

Hi :wave:t6: @HCawley , welcome to the forums and thanks so much for reaching out!

Can you give this resource a read and see if it helps you get unstuck?

If those resources do not help you please provide the following:

  • repo
  • site name/slug
  • what you have already tried
  • is it working locally

Thanks for providing this information. :slight_smile:

@HCawley Your issue is that your build command is set to npm run dev.

2:18:37 PM: $ npm run dev

It is executing next dev, which starts a long running server…

2:18:37 PM: > next dev
2:18:38 PM: ready - started server on 0.0.0.0:3000, url: http://localhost:3000

It then eventually times out…

2:53:51 PM: Build exceeded maximum allowed runtime

You cannot use the Netlify build server to host a web server.

You likely want to change your build command to npm run build.

1 Like