首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在docker中生成nextjs时出错,但它在本地工作。

在docker中生成nextjs时出错,但它在本地工作。
EN

Stack Overflow用户
提问于 2022-07-22 08:25:07
回答 1查看 528关注 0票数 2

我不能在docker中构建我的nextjs应用程序,但是在本地它没有任何错误。我添加了我的nextjs配置output: 'standalone'。我整个项目都是用纱线制作的。

我的Dockerfile与https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile完全相同,dockerignore与https://github.com/vercel/next.js/blob/canary/examples/with-docker/.dockerignore完全相同

错误:

代码语言:javascript
运行
复制
#13 0.556 $ next build
#13 0.866 info  - Loaded env from /app/.env
#13 1.081 Attention: Next.js now collects completely anonymous telemetry regarding usage.
#13 1.081 This information is used to shape Next.js' roadmap and prioritize features.
#13 1.081 You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
#13 1.081 https://nextjs.org/telemetry
#13 1.081
#13 1.198 info  - Linting and checking validity of types...
#13 1.544 error - ESLint must be installed in order to run during builds: yarn add --dev eslint
#13 1.552 info  - Creating an optimized production build...
#13 10.49 info  - Compiled successfully
#13 10.49 info  - Collecting page data...
#13 11.45 node:internal/child_process/serialization:127
#13 11.45     const string = JSONStringify(message) + '\n';
#13 11.45                    ^
#13 11.45
#13 11.45 TypeError: Converting circular structure to JSON
#13 11.45     --> starting at object with constructor 'Socket'
#13 11.45     |     property '_httpMessage' -> object with constructor 'ClientRequest'
#13 11.45     --- property 'socket' closes the circle
#13 11.45     at stringify (<anonymous>)
#13 11.45     at writeChannelMessage (node:internal/child_process/serialization:127:20)
#13 11.45     at process.target._send (node:internal/child_process:839:17)
#13 11.45     at process.target.send (node:internal/child_process:739:19)
#13 11.45     at reportError (/app/node_modules/next/dist/compiled/jest-worker/processChild.js:1:1995)
#13 11.45     at reportClientError (/app/node_modules/next/dist/compiled/jest-worker/processChild.js:1:1671)
#13 11.45     at processTicksAndRejections (node:internal/process/task_queues:96:5)
#13 12.07 node:internal/child_process/serialization:127
#13 12.07     const string = JSONStringify(message) + '\n';
#13 12.07                    ^
#13 12.07
#13 12.07 TypeError: Converting circular structure to JSON
#13 12.07     --> starting at object with constructor 'Socket'
#13 12.07     |     property '_httpMessage' -> object with constructor 'ClientRequest'
#13 12.07     --- property 'socket' closes the circle
#13 12.07     at stringify (<anonymous>)
#13 12.07     at writeChannelMessage (node:internal/child_process/serialization:127:20)
#13 12.07     at process.target._send (node:internal/child_process:839:17)
#13 12.07     at process.target.send (node:internal/child_process:739:19)
#13 12.07     at reportError (/app/node_modules/next/dist/compiled/jest-worker/processChild.js:1:1995)
#13 12.07     at reportClientError (/app/node_modules/next/dist/compiled/jest-worker/processChild.js:1:1671)
#13 12.07     at processTicksAndRejections (node:internal/process/task_queues:96:5)
#13 12.67 node:internal/child_process/serialization:127
#13 12.67     const string = JSONStringify(message) + '\n';
#13 12.67                    ^
#13 12.67
#13 12.67 TypeError: Converting circular structure to JSON
#13 12.67     --> starting at object with constructor 'Socket'
#13 12.67     |     property '_httpMessage' -> object with constructor 'ClientRequest'
#13 12.67     --- property 'socket' closes the circle
#13 12.67     at stringify (<anonymous>)
#13 12.67     at writeChannelMessage (node:internal/child_process/serialization:127:20)
#13 12.67     at process.target._send (node:internal/child_process:839:17)
#13 12.67     at process.target.send (node:internal/child_process:739:19)
#13 12.67     at reportError (/app/node_modules/next/dist/compiled/jest-worker/processChild.js:1:1995)
#13 12.67     at reportClientError (/app/node_modules/next/dist/compiled/jest-worker/processChild.js:1:1671)
#13 12.67     at processTicksAndRejections (node:internal/process/task_queues:96:5)
#13 13.29 node:internal/child_process/serialization:127
#13 13.29     const string = JSONStringify(message) + '\n';
#13 13.29                    ^
#13 13.29
#13 13.29 TypeError: Converting circular structure to JSON
#13 13.29     --> starting at object with constructor 'Socket'
#13 13.29     |     property '_httpMessage' -> object with constructor 'ClientRequest'
#13 13.29     --- property 'socket' closes the circle
#13 13.29     at stringify (<anonymous>)
#13 13.29     at writeChannelMessage (node:internal/child_process/serialization:127:20)
#13 13.29     at process.target._send (node:internal/child_process:839:17)
#13 13.29     at process.target.send (node:internal/child_process:739:19)
#13 13.29     at reportError (/app/node_modules/next/dist/compiled/jest-worker/processChild.js:1:1995)
#13 13.29     at reportClientError (/app/node_modules/next/dist/compiled/jest-worker/processChild.js:1:1671)
#13 13.29     at processTicksAndRejections (node:internal/process/task_queues:96:5)
#13 13.30
#13 13.30 > Build error occurred
#13 13.31 Error: Call retries were exceeded
#13 13.31     at ChildProcessWorker.initialize (/app/node_modules/next/dist/compiled/jest-worker/index.js:1:11661)
#13 13.31     at ChildProcessWorker._onExit (/app/node_modules/next/dist/compiled/jest-worker/index.js:1:12599)
#13 13.31     at ChildProcess.emit (node:events:527:28)
#13 13.31     at ChildProcess.emit (node:domain:475:12)
#13 13.31     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12) {
#13 13.31   type: 'WorkerError'
#13 13.31 }
#13 13.34 error Command failed with exit code 1.
#13 13.34 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
------
executor failed running [/bin/sh -c yarn build]: exit code: 1
EN

回答 1

Stack Overflow用户

发布于 2022-07-22 09:23:26

这看起来是一个bug (提到了这里这里),它是由jest中的循环引用引起的。您可以尝试使用不受此问题影响的较旧版本的解决办法之一。将以下内容添加到package.json

代码语言:javascript
运行
复制
    "resolutions": {
        "jest-jasmine2": "26.0.1"
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73077293

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档