1

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?

1 Answer 1

1

Yes, 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 forget to change those sources anywhere (especially if you're running the project with Docker).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.