Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Error: Cannot find module '/path/to/repo/dist/packages/package-web/.next/server/chunks/lib/worker.js' #52300

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

Closed
1 task done
maxime4000 opened this issue Jul 6, 2023 · 7 comments
Labels
bug Issue was opened via the bug report template. stale The issue has not seen recent activity.

Comments

@maxime4000
Copy link

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 22.5.0: Thu Jun  8 22:22:20 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T6000
    Binaries:
      Node: 18.16.0
      npm: 9.5.1
      Yarn: 1.22.19
      pnpm: 8.6.2
    Relevant Packages:
      next: 13.4.9-canary.2
      eslint-config-next: 13.4.6
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.1.6
    Next.js Config:
      output: N/A

Which area(s) of Next.js are affected? (leave empty if unsure)

App Router

Link to the code that reproduces this issue or a replay of the bug

Let me know if needed, not sure it's easy to reproduce as I don't understand what is wrong.

To Reproduce

So in the beginning, I was having this error. Try to resolve it by upgrading to latest next version, but it was still happening.

    ✖  nx run project-name-web:build:production
       - info Loaded env from /path/to/repo/packages/project-name-web/.env.local
       - info Loaded env from /path/to/repo/packages/project-name-web/.env
       - warn You have enabled experimental feature (serverActions) in next.config.js.
       - warn Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.
       
       - info Creating an optimized production build...
       - warn Compiled with warnings
       
       ../../node_modules/keyv/src/index.js
       Critical dependency: the request of a dependency is an expression
       
       Import trace for requested module:
       ../../node_modules/keyv/src/index.js
       ../../node_modules/cacheable-request/src/index.js
       ../../node_modules/got/dist/source/core/index.js
       ../../node_modules/got/dist/source/create.js
       ../../node_modules/got/dist/source/index.js
       ../../node_modules/@mapbox/mapbox-sdk/lib/node/node-layer.js
       ../../node_modules/@mapbox/mapbox-sdk/lib/node/node-client.js
       ../../node_modules/@mapbox/mapbox-sdk/lib/client.js
       ../../node_modules/@mapbox/mapbox-sdk/index.js
       ../../node_modules/@mapbox/mapbox-gl-geocoder/lib/index.js
       ./app/components/client/Map/MapSearch.tsx
       
       - info Skipping linting
       - info Checking validity of types...
       - info Collecting page data...
       
       node:internal/event_target:1012
         process.nextTick(() => { throw err; });
                                  ^
       Error: Cannot find module '/path/to/repo/dist/packages/project-name-web/.next/server/chunks/lib/worker.js'
           at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
           at Module._load (node:internal/modules/cjs/loader:920:27)
           at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
           at MessagePort.<anonymous> (node:internal/main/worker_thread:164:24)
           at [nodejs.internal.kHybridDispatch] (node:internal/event_target:737:20)
           at exports.emitMessage (node:internal/per_context/messageport:23:28)
       Emitted 'error' event on Worker instance at:
           at [kOnErrorMessage] (node:internal/worker:300:10)
           at [kOnMessage] (node:internal/worker:311:37)
           at MessagePort.<anonymous> (node:internal/worker:212:57)
           at [nodejs.internal.kHybridDispatch] (node:internal/event_target:737:20)
           at exports.emitMessage (node:internal/per_context/messageport:23:28)
           at MessagePort.callbackTrampoline (node:internal/async_hooks:130:17)
           at [kOnExit] (node:internal/worker:278:5)
           at Worker.<computed>.onexit (node:internal/worker:209:20)
           at Worker.callbackTrampoline (node:internal/async_hooks:130:17) {
         code: 'MODULE_NOT_FOUND',
         requireStack: []
       }
       
       Node.js v18.16.0
       Static worker unexpectedly exited with code: 1 and signal: null
       - info Generating static pages (0/13)
       - info Generating static pages (3/13)
       - info Generating static pages (6/13)
       - info Generating static pages (9/13)
       
       node:internal/event_target:1012
         process.nextTick(() => { throw err; });
                                  ^
       Error: Cannot find module '/path/to/repo/dist/packages/project-name-web/.next/server/chunks/lib/worker.js'
           at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
           at Module._load (node:internal/modules/cjs/loader:920:27)
           at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
           at MessagePort.<anonymous> (node:internal/main/worker_thread:164:24)
           at [nodejs.internal.kHybridDispatch] (node:internal/event_target:737:20)
           at exports.emitMessage (node:internal/per_context/messageport:23:28)
       Emitted 'error' event on Worker instance at:
           at [kOnErrorMessage] (node:internal/worker:300:10)
           at [kOnMessage] (node:internal/worker:311:37)
           at MessagePort.<anonymous> (node:internal/worker:212:57)
           at [nodejs.internal.kHybridDispatch] (node:internal/event_target:737:20)
           at exports.emitMessage (node:internal/per_context/messageport:23:28)
           at MessagePort.callbackTrampoline (node:internal/async_hooks:130:17)
           at [kOnExit] (node:internal/worker:278:5)
           at Worker.<computed>.onexit (node:internal/worker:209:20)
           at Worker.callbackTrampoline (node:internal/async_hooks:130:17) {
         code: 'MODULE_NOT_FOUND',
         requireStack: []
       }
       
       Node.js v18.16.0
       
       node:internal/event_target:1012
         process.nextTick(() => { throw err; });
                                  ^
       Error: Cannot find module '/path/to/repo/dist/packages/project-name-web/.next/server/chunks/lib/worker.js'
           at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
           at Module._load (node:internal/modules/cjs/loader:920:27)
           at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
           at MessagePort.<anonymous> (node:internal/main/worker_thread:164:24)
           at [nodejs.internal.kHybridDispatch] (node:internal/event_target:737:20)
           at exports.emitMessage (node:internal/per_context/messageport:23:28)
       Emitted 'error' event on Worker instance at:
           at [kOnErrorMessage] (node:internal/worker:300:10)
           at [kOnMessage] (node:internal/worker:311:37)
           at MessagePort.<anonymous> (node:internal/worker:212:57)
           at [nodejs.internal.kHybridDispatch] (node:internal/event_target:737:20)
           at exports.emitMessage (node:internal/per_context/messageport:23:28)
           at MessagePort.callbackTrampoline (node:internal/async_hooks:130:17)
           at [kOnExit] (node:internal/worker:278:5)
           at Worker.<computed>.onexit (node:internal/worker:209:20)
           at Worker.callbackTrampoline (node:internal/async_hooks:130:17) {
         code: 'MODULE_NOT_FOUND',
         requireStack: []
       }
       
       Node.js v18.16.0
       Static worker unexpectedly exited with code: 1 and signal: null
       Static worker unexpectedly exited with code: 1 and signal: null
       
       node:internal/event_target:1012
         process.nextTick(() => { throw err; });
                                  ^
       
       node:internal/event_target:1012
         process.nextTick(() => { throw err; });
                                  ^
       Error: Cannot find module '/path/to/repo/dist/packages/project-name-web/.next/server/chunks/lib/worker.js'
           at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
           at Module._load (node:internal/modules/cjs/loader:920:27)
           at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
           at MessagePort.<anonymous> (node:internal/main/worker_thread:164:24)
           at [nodejs.internal.kHybridDispatch] (node:internal/event_target:737:20)
           at exports.emitMessage (node:internal/per_context/messageport:23:28)
       Emitted 'error' event on Worker instance at:
           at [kOnErrorMessage] (node:internal/worker:300:10)
           at [kOnMessage] (node:internal/worker:311:37)
           at MessagePort.<anonymous> (node:internal/worker:212:57)
           at [nodejs.internal.kHybridDispatch] (node:internal/event_target:737:20)
           at exports.emitMessage (node:internal/per_context/messageport:23:28)
           at MessagePort.callbackTrampoline (node:internal/async_hooks:130:17)
           at [kOnExit] (node:internal/worker:278:5)
           at Worker.<computed>.onexit (node:internal/worker:209:20)
           at Worker.callbackTrampoline (node:internal/async_hooks:130:17) {
         code: 'MODULE_NOT_FOUND',
         requireStack: []
       }
       
       Node.js v18.16.0
       Error: Cannot find module '/path/to/repo/dist/packages/project-name-web/.next/server/chunks/lib/worker.js'
           at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
           at Module._load (node:internal/modules/cjs/loader:920:27)
           at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
           at MessagePort.<anonymous> (node:internal/main/worker_thread:164:24)
           at [nodejs.internal.kHybridDispatch] (node:internal/event_target:737:20)
           at exports.emitMessage (node:internal/per_context/messageport:23:28)
       Emitted 'error' event on Worker instance at:
           at [kOnErrorMessage] (node:internal/worker:300:10)
           at [kOnMessage] (node:internal/worker:311:37)
           at MessagePort.<anonymous> (node:internal/worker:212:57)
           at [nodejs.internal.kHybridDispatch] (node:internal/event_target:737:20)
           at exports.emitMessage (node:internal/per_context/messageport:23:28)
           at MessagePort.callbackTrampoline (node:internal/async_hooks:130:17)
           at [kOnExit] (node:internal/worker:278:5)
           at Worker.<computed>.onexit (node:internal/worker:209:20)
           at Worker.callbackTrampoline (node:internal/async_hooks:130:17) {
         code: 'MODULE_NOT_FOUND',
         requireStack: []
       }
       
       Node.js v18.16.0
       
       node:internal/event_target:1012
         process.nextTick(() => { throw err; });
                                  ^
       
       node:internal/event_target:1012
         process.nextTick(() => { throw err; });
                                  ^
       Error: Cannot find module '/path/to/repo/dist/packages/project-name-web/.next/server/chunks/lib/worker.js'
           at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
           at Module._load (node:internal/modules/cjs/loader:920:27)
           at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
           at MessagePort.<anonymous> (node:internal/main/worker_thread:164:24)
           at [nodejs.internal.kHybridDispatch] (node:internal/event_target:737:20)
           at exports.emitMessage (node:internal/per_context/messageport:23:28)
       Emitted 'error' event on Worker instance at:
           at [kOnErrorMessage] (node:internal/worker:300:10)
           at [kOnMessage] (node:internal/worker:311:37)
           at MessagePort.<anonymous> (node:internal/worker:212:57)
           at [nodejs.internal.kHybridDispatch] (node:internal/event_target:737:20)
           at exports.emitMessage (node:internal/per_context/messageport:23:28)
           at MessagePort.callbackTrampoline (node:internal/async_hooks:130:17)
           at [kOnExit] (node:internal/worker:278:5)
           at Worker.<computed>.onexit (node:internal/worker:209:20)
           at Worker.callbackTrampoline (node:internal/async_hooks:130:17) {
         code: 'MODULE_NOT_FOUND',
         requireStack: []
       }
       
       Node.js v18.16.0
       Error: Cannot find module '/path/to/repo/dist/packages/project-name-web/.next/server/chunks/lib/worker.js'
           at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
           at Module._load (node:internal/modules/cjs/loader:920:27)
           at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
           at MessagePort.<anonymous> (node:internal/main/worker_thread:164:24)
           at [nodejs.internal.kHybridDispatch] (node:internal/event_target:737:20)
           at exports.emitMessage (node:internal/per_context/messageport:23:28)
       Emitted 'error' event on Worker instance at:
           at [kOnErrorMessage] (node:internal/worker:300:10)
           at [kOnMessage] (node:internal/worker:311:37)
           at MessagePort.<anonymous> (node:internal/worker:212:57)
           at [nodejs.internal.kHybridDispatch] (node:internal/event_target:737:20)
           at exports.emitMessage (node:internal/per_context/messageport:23:28)
           at MessagePort.callbackTrampoline (node:internal/async_hooks:130:17)
           at [kOnExit] (node:internal/worker:278:5)
           at Worker.<computed>.onexit (node:internal/worker:209:20)
           at Worker.callbackTrampoline (node:internal/async_hooks:130:17) {
         code: 'MODULE_NOT_FOUND',
         requireStack: []
       }
       
       Node.js v18.16.0
       
       node:internal/event_target:1012
         process.nextTick(() => { throw err; });
                                  ^
       
       node:internal/event_target:1012
         process.nextTick(() => { throw err; });
                                  ^
       Error: Cannot find module '/path/to/repo/dist/packages/project-name-web/.next/server/chunks/lib/worker.js'
           at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
           at Module._load (node:internal/modules/cjs/loader:920:27)
           at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
           at MessagePort.<anonymous> (node:internal/main/worker_thread:164:24)
           at [nodejs.internal.kHybridDispatch] (node:internal/event_target:737:20)
           at exports.emitMessage (node:internal/per_context/messageport:23:28)
       Emitted 'error' event on Worker instance at:
           at [kOnErrorMessage] (node:internal/worker:300:10)
           at [kOnMessage] (node:internal/worker:311:37)
           at MessagePort.<anonymous> (node:internal/worker:212:57)
           at [nodejs.internal.kHybridDispatch] (node:internal/event_target:737:20)
           at exports.emitMessage (node:internal/per_context/messageport:23:28)
           at MessagePort.callbackTrampoline (node:internal/async_hooks:130:17)
           at [kOnExit] (node:internal/worker:278:5)
           at Worker.<computed>.onexit (node:internal/worker:209:20)
           at Worker.callbackTrampoline (node:internal/async_hooks:130:17) {
         code: 'MODULE_NOT_FOUND',
         requireStack: []
       }
       
       Node.js v18.16.0
       Error: Cannot find module '/path/to/repo/dist/packages/project-name-web/.next/server/chunks/lib/worker.js'
           at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
           at Module._load (node:internal/modules/cjs/loader:920:27)
           at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
           at MessagePort.<anonymous> (node:internal/main/worker_thread:164:24)
           at [nodejs.internal.kHybridDispatch] (node:internal/event_target:737:20)
           at exports.emitMessage (node:internal/per_context/messageport:23:28)
       Emitted 'error' event on Worker instance at:
           at [kOnErrorMessage] (node:internal/worker:300:10)
           at [kOnMessage] (node:internal/worker:311:37)
           at MessagePort.<anonymous> (node:internal/worker:212:57)
           at [nodejs.internal.kHybridDispatch] (node:internal/event_target:737:20)
           at exports.emitMessage (node:internal/per_context/messageport:23:28)
           at MessagePort.callbackTrampoline (node:internal/async_hooks:130:17)
           at [kOnExit] (node:internal/worker:278:5)
           at Worker.<computed>.onexit (node:internal/worker:209:20)
           at Worker.callbackTrampoline (node:internal/async_hooks:130:17) {
         code: 'MODULE_NOT_FOUND',
         requireStack: []
       }
       
       Node.js v18.16.0
       
       > Build error occurred
       Error: Call retries were exceeded
           at ChildProcessWorker.initialize (/path/to/repo/node_modules/next/dist/compiled/jest-worker/index.js:1:11661)
           at ChildProcessWorker._onExit (/path/to/repo/node_modules/next/dist/compiled/jest-worker/index.js:1:12599)
           at ChildProcess.emit (node:events:513:28)
           at ChildProcess.emit (node:domain:489:12)
           at ChildProcess._handle.onexit (node:internal/child_process:291:12) {
         type: 'WorkerError'
       }
       Error occurred while trying to run the npx next build 
       Error: Command failed: npx next build 
           at checkExecSyncError (node:child_process:885:11)
           at execSync (node:child_process:957:15)
           at /path/to/repo/node_modules/@nx/next/src/executors/build/build.impl.js:46:42
           at Generator.next (<anonymous>)
           at /path/to/repo/node_modules/tslib/tslib.js:167:75
           at new Promise (<anonymous>)
           at Object.__awaiter (/path/to/repo/node_modules/tslib/tslib.js:163:16)
           at buildExecutor (/path/to/repo/node_modules/@nx/next/src/executors/build/build.impl.js:20:20)
           at /path/to/repo/node_modules/nx/src/command-line/run/run.js:113:23

So I was going to report a bug, but I try next@canary and now I have a new bug for tsx syntax?

    ✖  nx run project-name-web:build:production
       - info Loaded env from /path/to/repo/packages/project-name-web/.env.local
       - info Loaded env from /path/to/repo/packages/project-name-web/.env
       - warn You have enabled experimental feature (serverActions) in next.config.js.
       - warn Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.
       
       - info Creating an optimized production build...
       Failed to compile.
       
       ../project-name-ui/src/lib/Box/Box.tsx
       Module parse failed: Unexpected token (7:7)
       You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
       | import Flex, { FlexProps } from "../Flex/Flex";
       | 
       > export type BoxProps = FlexProps & AriaAttributes;
       | 
       | const BoxElement = styled(Flex)`
       
       Import trace for requested module:
       ../project-name-ui/src/lib/Box/Box.tsx
       ../project-name-ui/src/index.ts
       ./app/[locale]/buildings/[id]/schema/page.tsx
       
       ../project-name-ui/src/lib/Button/Button.tsx
       Module parse failed: Unexpected token (7:7)
       You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
       | import { State } from "../Theme/Theme.types";
       | 
       > export enum ButtonSize {
       |        Sm = "sm",
       |        Md = "md",
       
       Import trace for requested module:
       ../project-name-ui/src/lib/Button/Button.tsx
       ../project-name-ui/src/lib/Button/index.ts
       ../project-name-ui/src/index.ts
       ./app/[locale]/buildings/[id]/schema/page.tsx
       
       ../project-name-ui/src/lib/ColorPicker/ColorPicker.tsx
       Module parse failed: Unexpected token (7:7)
       You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
       | import ColorTag from "./ColorTag";
       | 
       > export type ColorPickerProps = {
       |        colors: string[];
       | };
       
       Import trace for requested module:
       ../project-name-ui/src/lib/ColorPicker/ColorPicker.tsx
       ../project-name-ui/src/lib/ColorPicker/index.ts
       ../project-name-ui/src/index.ts
       ./app/[locale]/buildings/[id]/schema/page.tsx
       
       ../project-name-ui/src/lib/ColorPicker/ColorTag.tsx
       Module parse failed: Unexpected token (6:7)
       You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
       | import Flex, { FlexProps } from "../Flex/Flex";
       | 
       > export type ColorTagProps = {
       |        color: string;
       |        selected?: boolean;
       
       Import trace for requested module:
       ../project-name-ui/src/lib/ColorPicker/ColorTag.tsx
       ../project-name-ui/src/lib/ColorPicker/index.ts
       ../project-name-ui/src/index.ts
       ./app/[locale]/buildings/[id]/schema/page.tsx
       
       ../project-name-ui/src/lib/Dialog/Dialog.tsx
       Module parse failed: The keyword 'interface' is reserved (7:0)
       You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
       | import { Flex } from "../Flex/Flex";
       | 
       > interface DialogCSSProps {
       |        width?: string;
       |        height?: string;
       
       Import trace for requested module:
       ../project-name-ui/src/lib/Dialog/Dialog.tsx
       ../project-name-ui/src/lib/Dialog/index.ts
       ../project-name-ui/src/index.ts
       ./app/[locale]/buildings/[id]/schema/page.tsx
       
       
       > Build failed because of webpack errors
       Error occurred while trying to run the npx next build 
       Error: Command failed: npx next build 
           at checkExecSyncError (node:child_process:885:11)
           at execSync (node:child_process:957:15)
           at /path/to/repo/node_modules/@nx/next/src/executors/build/build.impl.js:49:42
           at Generator.next (<anonymous>)
           at /path/to/repo/node_modules/tslib/tslib.js:169:75
           at new Promise (<anonymous>)
           at Object.__awaiter (/path/to/repo/node_modules/tslib/tslib.js:165:16)
           at buildExecutor (/path/to/repo/node_modules/@nx/next/src/executors/build/build.impl.js:20:20)
           at /path/to/repo/node_modules/nx/src/command-line/run/run.js:101:23

Describe the Bug

Because our app we are working is still small, we decide to port all our routes to the app directory. That was done and serving the app was not perfect but working. Tho, when we are trying to build our app, here where this log appear. We don't have static page, so we don't understand why the process happen.

Updating next to canary, change the error for a typescript syntax error which isn't an error. The code is fine and shouldn't be an issue.

Expected Behavior

Next being able to build ?

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

@maxime4000 maxime4000 added the bug Issue was opened via the bug report template. label Jul 6, 2023
@maxime4000 maxime4000 changed the title Error: Cannot find module '/Users/maxime/Repo/eddie/dist/packages/eddie-web/.next/server/chunks/lib/worker.js' Error: Cannot find module '/path/to/repo/dist/packages/package-web/.next/server/chunks/lib/worker.js' Jul 6, 2023
@masterbater
Copy link

delete .next folder

@maxime4000
Copy link
Author

Already done

@maxime4000
Copy link
Author

Ok so 13.3.0 work for us, but going to 13.4.6 or 13.4.8 or canary doesn't work...

@maxime4000
Copy link
Author

Update : 13.3.0 has no issue, 13.3.1 has the issue

@fazo96
Copy link

fazo96 commented Nov 1, 2023

Hi, we are on 13.5.1 and we have the same issue. We aren't considering downgrading so we are waiting on a fix to be able to convert our pages to the new app router.

It would be nice to get this fixed because with the new app router we can have different sections of our site with different layouts and that's something we plan to take advantage of.

@nextjs-bot
Copy link
Collaborator

This issue has been automatically marked as stale due to two years of inactivity. It will be closed in 7 days unless there’s further input. If you believe this issue is still relevant, please leave a comment or provide updated details. Thank you.

@nextjs-bot nextjs-bot added the stale The issue has not seen recent activity. label Apr 29, 2025
@nextjs-bot
Copy link
Collaborator

This issue has been automatically closed due to two years of inactivity. If you’re still experiencing a similar problem or have additional details to share, please open a new issue following our current issue template. Your updated report helps us investigate and address concerns more efficiently. Thank you for your understanding!

@nextjs-bot nextjs-bot closed this as not planned Won't fix, can't repro, duplicate, stale May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. stale The issue has not seen recent activity.
Projects
None yet
Development

No branches or pull requests

4 participants