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

vilbur's avatar

How to deploy npm modules to live server ?

Hello everybody, I have just start using npm, elixir and it seems to be great. But there are a few things that do not appear clear to me. I installed some 'laravel-elixir' packages, and what surprised me first time, how huge is node_modules folder (220 MB in 856 main dirs)... But I found, that this is normal, what surprised me second time ;) ...

When publishing node modules is done with:

elixir(function(mix) {
    mix.copy('node_modules/foo/bar.css', 'public/css/bar.css');
});

What happens with all these dependencies? Are they still sourced from node_modules folder, and I need to copy node_modules folder to live server. Or is it so clever, that these dependencies will be merged? So I don`t need node_modules folder on live server ?
Please can you explain this mystery, you all surely know ? ;)

0 likes
1 reply
AliBayat's avatar

all those file in "node_modules" folder are dependencies for your project and defined in package.json file. you usually require all modules and convert all your ES6 and javascript codes into a single bundle file using webpack, or any other tool. in this case you dont need to upload "node_modules" folder on your server. all you need is that bundle file.

but if you need development environment on your server then thats the other case, so you should install nodejs on the server, upload your package.json file and run 'npm install' on server using ssh

1 like

Please or to participate in this conversation.