What are the best practices to integrate Node.js libraries in an existing client-server php (laravel) web app?

Hi,
I work mainly on a lamp stack with building webapps with Laravel
Of course I use a lot of JS libraries but in those last couple of years I gradually find more and more tools or projects that offer Js libraries (Cool, let’s implement into my webapp! :smile:) that in the end are made on node.js ( arrghh! :dizzy_face: )

The usual scenario I find is an example with a client and a server that should run on different ports and you need to start them by launching a npm run start command or something similar…and then I start questioning how to interact with those script, how to automate their launch, how all this could be scalable and organized
As an alternative I know that is possible to convert and bundle node modules with webpack or browserify but I’m not sure if it doable for the above scenarios and if that is the right approach.
Moreover I don’t want to spend days to turn on webpack or browserify properly … to me seems some sort of fragmentation and complexification in frontend development.

How do you approach it? Is there a suggested workflow?

You should add them as dependencies in your package.json . You can then use Laravel Mix, which is a high-level DSL over webpack. Basically it’s as simple as npm run dev and mix/webpack takes it from there.

https://laravel.com/docs/7.x/mix