No node entry point after `npm run build` in Next 15
Answered
Himalayan posted this in #help-forum
HimalayanOP
why isn't
Where is my node
npm run build
showing an entry point for next 15, it should be something like node .next/server.js
or node .next/server/index.js
or something. But the output is just: my-app git:(main) npm run build
> my-app@0.1.0 build
> next build
▲ Next.js 15.0.2
Creating an optimized production build ...
✓ Compiled successfully
✓ Linting and checking validity of types
✓ Collecting page data
✓ Generating static pages (5/5)
✓ Collecting build traces
✓ Finalizing page optimization
Route (app) Size First Load JS
┌ ○ / 5.46 kB 105 kB
└ ○ /_not-found 897 B 101 kB
+ First Load JS shared by all 99.7 kB
├ chunks/215-f207ea7968f9b6d8.js 45.2 kB
├ chunks/4bd1b696-23516f99b565b560.js 52.6 kB
└ other shared chunks (total) 1.88 kB
○ (Static) prerendered as static content
Where is my node
Answered by joulev
by default, it expects you to start the thing by
if you want an entry point and a standalone folder that you can copy to any machine to deploy the app there, you can use standalone output: https://nextjs.org/docs/app/api-reference/next-config-js/output#automatically-copying-traced-files
next start
.if you want an entry point and a standalone folder that you can copy to any machine to deploy the app there, you can use standalone output: https://nextjs.org/docs/app/api-reference/next-config-js/output#automatically-copying-traced-files
25 Replies
@Himalayan why isn't `npm run build` showing an entry point for next 15, it should be something like `node .next/server.js` or `node .next/server/index.js` or something. But the output is just:
my-app git:(main) npm run build
> my-app@0.1.0 build
> next build
▲ Next.js 15.0.2
Creating an optimized production build ...
✓ Compiled successfully
✓ Linting and checking validity of types
✓ Collecting page data
✓ Generating static pages (5/5)
✓ Collecting build traces
✓ Finalizing page optimization
Route (app) Size First Load JS
┌ ○ / 5.46 kB 105 kB
└ ○ /_not-found 897 B 101 kB
+ First Load JS shared by all 99.7 kB
├ chunks/215-f207ea7968f9b6d8.js 45.2 kB
├ chunks/4bd1b696-23516f99b565b560.js 52.6 kB
└ other shared chunks (total) 1.88 kB
○ (Static) prerendered as static content
Where is my node
by default, it expects you to start the thing by
if you want an entry point and a standalone folder that you can copy to any machine to deploy the app there, you can use standalone output: https://nextjs.org/docs/app/api-reference/next-config-js/output#automatically-copying-traced-files
next start
.if you want an entry point and a standalone folder that you can copy to any machine to deploy the app there, you can use standalone output: https://nextjs.org/docs/app/api-reference/next-config-js/output#automatically-copying-traced-files
Answer
HimalayanOP
the plan is to run it on my machine locally it's a utility project for my personal use
yeah then just
next start
, if not, standalone output is still a feasible option, you have a server.js
that you can simply node
it@joulev yeah then just `next start`, if not, standalone output is still a feasible option, you have a `server.js` that you can simply `node` it
HimalayanOP
I am asking for the "node" entry point. e.g. in Nuxt the node entry point is here:
.output/server/index.mjs
and you run it like node .output/server/index.mjs
Where is it in Next 15?
@joulev yeah then just `next start`, if not, standalone output is still a feasible option, you have a `server.js` that you can simply `node` it
HimalayanOP
Where do I have
server.js
file? Can't find it anywhere in the final build.@Himalayan I am asking for the "node" entry point. e.g. in Nuxt the node entry point is here: `.output/server/index.mjs` and you run it like `node .output/server/index.mjs`
yeah i know and i've been telling you to use standalone output, then it will be available in the final build
are you using
output: "standalone"
?HimalayanOP
I am not familiar with this setup.
go read the link i provided above
HimalayanOP
is it somewhere in docs?
ok, thanks. Do you know why it isn't default option?
well... i don't know, honestly. i'm not part of the team
HimalayanOP
ok, now I have the server.js file in
.next/standalone/server.js
but the image links and css is broken 😭 I run it via: node .next/standalone/server.js
HimalayanOP
Any idea how to fix that?
Why isn't server.js picking up the images and css?
@Himalayan ok, now I have the server.js file in `.next/standalone/server.js` but the image links and css is broken 😭 I run it via: `node .next/standalone/server.js`
static assets are not served by default because most of the times you would want to move them to a CDN and serve them there instead
to serve them you just need to copy
.next/static
to .next/standalone/.next/static
i just tested in a nextjs app i have and it works fine
@joulev to serve them you just need to copy `.next/static` to `.next/standalone/.next/static`
HimalayanOP
Thanks, I copied it there and now I have this:
But Images are still missing 😭
But Images are still missing 😭
@Himalayan Thanks, I copied it there and now I have this:
But Images are still missing 😭
what are the image URLs?
if they are the images in
public
folder, you need to copy it to the standalone folder too for the same reasonAdditionally, a minimal server.js file is also output which can be used instead of next start. This minimal server does not copy the public or .next/static folders by default as these should ideally be handled by a CDN instead, although these folders can be copied to the standalone/public and standalone/.next/static folders manually, after which server.js file will serve these automatically.
@joulev what are the image URLs?
HimalayanOP
Thanks! Finally it works after copying public/ folder to standalone/ 😉