最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

laravel - Importing node_modules from a dedicated Node.js project - Stack Overflow

programmeradmin1浏览0评论

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 badges
Add a comment  | 

1 Answer 1

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

发布评论

评论列表(0)

  1. 暂无评论