I am currently Using Laravel 10 (I know it's outdated and I will upgrade asap), and I have node_modules
folder inside the project because i installed some npm modules that I need.
But I need to move the node_modules
to a separate Node.js-only project and somehow make the Laravel project use the node_modules
from there.
Right now the structure is:
laravel-project
|______node_modules
|________some-module
|________some-other-module
But I need it to be:
laravel-project
nodejs-project
|______node_modules
|________some-module
|________some-other-module
Is such thing possible?
I am currently Using Laravel 10 (I know it's outdated and I will upgrade asap), and I have node_modules
folder inside the project because i installed some npm modules that I need.
But I need to move the node_modules
to a separate Node.js-only project and somehow make the Laravel project use the node_modules
from there.
Right now the structure is:
laravel-project
|______node_modules
|________some-module
|________some-other-module
But I need it to be:
laravel-project
nodejs-project
|______node_modules
|________some-module
|________some-other-module
Is such thing possible?
Share Improve this question asked Mar 31 at 9:28 pileuppileup 3,3025 gold badges30 silver badges69 bronze badges1 Answer
Reset to default 1Yes, you can move your node modules to outside of the project and symlink it via
going into your laravel project and
ln -s /path/to/node_modules node_modules
This approach should minimize the need for adjustments in paths
Another way you can achieve it is by setting up your vite or mix to reference a folder outside of the project.
There are a few other ways, all dealing with configuration paths.
I do have to mention that I really don't recommend doing it as the idea of laravel is to wrap your project completely, and if you do this you will need to do it in any project you might want to launch or move anywhere.
If you do decide you want to take such an approach, don't fet to change those sources anywhere (especially if you're running the project with Docker).