Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

aekramer's avatar

New to laravel 10 - npm run dev on production server?

Hi all, I have just started getting back into laravel (last time I actively used it, still a beginner though, was version 5) so this is all a big difference for me. Just going through the Whats new in 10 series and afterwards the getting started in laravel 8 series.

But my question so far is, after installing laravel with breeze scaffolding for all the auth controllers and such, I am now required to run the npm server as well, does this mean this is also required on the production server then?

What would be the best way to actually run it on the server if that's the case?

0 likes
4 replies
LaryAI's avatar
LaryAI
AI
Best Answer
Level 58

No, it is not necessary to run npm run dev on the production server. This command is used to compile assets during development.

For production, you should run npm run prod instead, which will minify and optimize the assets for production use.

To run this command on the server, you can SSH into the server and navigate to the project directory. Then, run the following command:

npm run prod

This will compile the assets and place them in the public directory, which can be served by your web server.

aekramer's avatar

@LaryAI Damn that's fast. Gotta love A.I...

What would be the best way to run this "as a service" similair how nginx/mysql etc would be running on an ubuntu server?

EDIT: From my research so far, it seems like "pm2" (Process Manager 2) can work similairly to how I am familair with systemctl for nginx etc.

Snapey's avatar

@aekramer Just part of your deployment script. Not a continuously running service (same as you would for composer install)

Personally I prefer to compile locally and then ship the built assets via the repository, but views are divided on this.

aekramer's avatar

@Snapey I would prefer this too, but currently my local version will not display some of the auth pages like register if I am not also running "npc run dev"

I would assume the same thing happens if I were to push these files to the production server?

EDIT: I believe I figured it out, thank you.

I can simply run "npm run build" which will compile the files into public/build folder

Please or to participate in this conversation.