运行 带有样式组件的下一个 js 应用程序出现内部服务器错误

I get internal server error while running next js app with styled component

我正在使用 Next.js 和 styledcomponent,它在开发模式下没有错误。但是 运行 在构建生产模式下。我得到一个错误。没有行号或文件名。

我也开了一个issue Github https://github.com/zeit/next.js/issues/5932

ERROR

NODE_ENV=production node server.js

Ready on http://localhost:3000 Error: An error occurred. See https://github.com/styled-components/styled-components/blob/master/src/utils/errors.md#1 for more information. Additional arguments: undefined at new StyledComponentsError (/Users/rahulkishan/Documents/React_Mobile_and_web/ReactWebV1/purchaseweb/node_modules/styled-components/dist/styled-components.cjs.js:161:58) at constructWithOptions (/Users/rahulkishan/Documents/React_Mobile_and_web/ReactWebV1/purchaseweb/node_modules/styled-components/dist/styled-components.cjs.js:2182:13) at styled (/Users/rahulkishan/Documents/React_Mobile_and_web/ReactWebV1/purchaseweb/node_modules/styled-components/dist/styled-components.cjs.js:2126:12) at Object. (/Users/rahulkishan/Documents/React_Mobile_and_web/ReactWebV1/purchaseweb/.next/server/static/i2aIDkRZkhvVhtPxvk4BE/pages/index.js:4504:77)

为什么它仅在构建模式下显示此错误。不在开发模式。 我们已经构建了一个大型应用程序。 确实很难找到问题。

错误自有其路径

static/../pages/index.js

还有行号

给予后npm run build

Nexts js 创建一个构建文件夹

/.next/server/static

在该文件夹中,您将能够看到完整的生产代码。