Comments (10)
@marijaduvnjak You should be able to fix this by using the serverComponentsExternalPackages.
Example:
/** @type {import('next').NextConfig} */
const nextConfig = {
poweredByHeader: false,
output: "standalone",
experimental: {
instrumentationHook: true,
serverComponentsExternalPackages: ["dd-trace"],
},
devIndicators: {
buildActivity: false,
},
eslint: {
ignoreDuringBuilds: true,
},
};
from next.js.
`❯ nr
✔ script to run › build
[email protected] build /path/to/project
next build
▲ Next.js 14.2.1
- Environments: .env
Creating an optimized production build ...
✓ Compiled successfully
✓ Linting and checking validity of types
✓ Collecting page data
Generating static pages (5/14) [= ]Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
at nM (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:61599)
at nM (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:61546)
at nN (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:64546)
at nB (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:67538)
at nD (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:66680)
at nN (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:64853)
at nB (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:67538)
at nM (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:58560)
at nN (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:64546)
at nB (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:67538)
at nB (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:67538) {
digest: '839973123'
}
Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
at nM (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:61599)
at nM (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:61546)
at nN (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:64546)
at nB (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:67538)
at nD (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:66680)
at nN (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:64853)
at nB (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:67538)
at nM (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:58560)
at nN (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:64546)
at nB (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:67538)
✓ Generating static pages (14/14)
Export encountered errors on following paths:
/page: /
ELIFECYCLE Command failed with exit code 1.`
getting this error on build in >= v14.2
working fine in < v14.2
from next.js.
I was facing the same issue. Came to know from Reddit that a specific PR is waiting to fix this issue.
from next.js.
Coming from a related issue, adding "dd-trace" fixed the issue for me.
When I run next dev --turbo
, I get the error even with dd-trace
added to serverComponentsExternalPackages
from next.js.
Seems something related to how dd-trace
is now being bundled in instrumentation.ts
. I haven't worked on that part of Next.js personally but will raise it to the right people 👍
from next.js.
from next.js.
@marijaduvnjak You should be able to fix this by using the serverComponentsExternalPackages.
Example:
/** @type {import('next').NextConfig} */ const nextConfig = { poweredByHeader: false, output: "standalone", experimental: { instrumentationHook: true, serverComponentsExternalPackages: ["dd-trace"], }, devIndicators: { buildActivity: false, }, eslint: { ignoreDuringBuilds: true, }, };
thanks a lot, coltonehrman, it works like a charm! 😃
just for curiosity: why do we need to add now dd-trace in serverComponentsExternalPackages? is there any change from changelogs in v14.2 that pointed out that we need to be aware of doing this change (and I overlooked it somehow 😅)?
from next.js.
`❯ nr ✔ script to run › build
[email protected] build /path/to/project
next build
▲ Next.js 14.2.1
- Environments: .env
Creating an optimized production build ...
✓ Compiled successfully
✓ Linting and checking validity of types
✓ Collecting page data
Generating static pages (5/14) [= ]Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
at nM (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:61599)
at nM (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:61546)
at nN (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:64546)
at nB (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:67538)
at nD (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:66680)
at nN (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:64853)
at nB (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:67538)
at nM (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:58560)
at nN (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:64546)
at nB (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:67538)
at nB (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:67538) {
digest: '839973123'
}
Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
at nM (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:61599)
at nM (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:61546)
at nN (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:64546)
at nB (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:67538)
at nD (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:66680)
at nN (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:64853)
at nB (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:67538)
at nM (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:58560)
at nN (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:64546)
at nB (/path/to/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:67538)
✓ Generating static pages (14/14)Export encountered errors on following paths:
/page: /
ELIFECYCLE Command failed with exit code 1.`getting this error on build in >= v14.2
working fine in < v14.2
maybe it's related to this issue: #64369 (comment)
from next.js.
serverComponentsExternalPackages didn't work when using pnpm... had to resort to this fix- #43433 (comment)
webpack: (config) => {
config.externals.push({
"dd-trace": "commonjs dd-trace",
})
return config
},
from next.js.
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
from next.js.
Related Issues (20)
- Problem with postcss transformation when importing css with layer HOT 1
- ReactRemoveProperties dosen't work as it was
- Turbopack dev server and HMR consuming too much memory and freezing at code changes. HOT 21
- TypeError: Failed to parse URL from /api/images HOT 9
- Vercel + pages router + basePath + middleware - Full roundtrip when client navigating to index page HOT 2
- Refractor languages missing when Turbopack is enabled HOT 1
- "trailingSlash" causing CORS errors HOT 1
- Version 15 breaks select form element
- Docs: Versioned Documentation HOT 4
- Docs: inaccuracy in React Foundations (Chapter 4) HOT 4
- Sitemap is being generated incorrectly and an error in development also appears when I try to access /sitemap.xml HOT 13
- Cannot use Sharp in v15.0.0-canary.1 HOT 11
- NextJS 14 returns fetch failed with UND_ERR_CONNECT_TIMEOUT error on serverless function HOT 26
- enable swcMinify compression exception { toString, fromString } => {fromString} HOT 2
- Tailwind content for projects with "src" folder doesn't works HOT 1
- create-next-app v15 rc with --empty and src directory results in a broken tailwind.config.ts HOT 2
- vercel/styled-jsx error `DOMException: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.` HOT 1
- Build Error: Parsing css source code failed HOT 6
- Route Handlers Crash with bcrypt (see: #46493) HOT 5
- Forms example does not work with useActionState HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from next.js.