Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the node_modules folder for in Laravel?

When I open a new Laravel project in PhpStorm I am asked to run npm install to install project dependencies. I am assuming that Laravel has some node.js dependencies but searching on Google I can't find a definitive answer.

  1. Are these node.js modules part of the Laravel project or some PhpStorm functionality?
  2. What part does it play in Laravel and/or PhpStorm?

I'm using Laravel 5.7

like image 269
David Johnson Avatar asked Jan 29 '19 02:01

David Johnson


People also ask

What is node_modules folder for?

The node_modules folder is used to save all downloaded packages from npm in your computer for the JavaScript project that you have. Developers are always recommended to do a fresh install with npm install each time they downloaded a JavaScript project into their computer.

What is the use of node modules folder in angular?

node_modules/ − The npm package installed is node_modules. You can open the folder and see the packages available. src/ − This folder is where we will work on the project using Angular 7. Inside src/ you will app/ folder created during the project setup and holds all the required files required for the project.

What is stored in the node_modules directory of your node application folder?

The node_modules folder contains every installed dependency for your project. In most cases, you should not commit this folder into your version controlled repository. As you install more dependencies, the size of this folder will quickly grow. Furthermore, the package-lock.

Where is node_modules folder?

On Unix systems they are normally placed in /usr/local/lib/node or /usr/local/lib/node_modules when installed globally. If you set the NODE_PATH environment variable to this path, the modules can be found by node. Non-global libraries are installed the node_modules sub folder in the folder you are currently in.


2 Answers

When you install laravel you will got a folder called vendor in your project. In this folder you have got all the pacakge dependencies of the laravel. And All those packages and their dependencies are listed in composer.json.

Same as node_modules folder also contains the package dependencies related to your javascript projects. So, that you can require it in your projects. And All those packages and their dependencies are listed in package.json.

In your case if you are not using vue.js,react.js then you don't need to run npm install . You can start building project without worrying about node_modules. You can even delete this folder and install it again using npm install when required.

like image 101
Anand Mainali Avatar answered Oct 25 '22 16:10

Anand Mainali


The default install of Laravel includes a starter Vue.js application, as well as Webpack and Laravel Mix. These use Node.

If you don't intend to use these, you can safely remove node_modules, the starter Vue app, and package.json in your Laravel install.

They have nothing to do with PHPStorm.

edit: In recent versions of Laravel, the command php artisan preset none will remove the Vue starter app.

like image 43
ceejayoz Avatar answered Oct 25 '22 17:10

ceejayoz