Laravel 中的 node_modules 文件夹是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/54413224/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 18:15:44  来源:igfitidea点击:

What is the node_modules folder for in Laravel?

node.jslaravelphpstorm

提问by user279898100

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

当我在 PhpStorm 中打开一个新的 Laravel 项目时,我被要求运行npm install以安装项目依赖项。我假设 Laravel 有一些 node.js 依赖项,但在 Google 上搜索我找不到明确的答案。

  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?
  1. 这些 node.js 模块是 Laravel 项目的一部分还是某些 PhpStorm 功能?
  2. 它在 Laravel 和/或 PhpStorm 中扮演什么角色?

I'm using Laravel 5.7

我正在使用 Laravel 5.7

回答by ceejayoz

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

Laravel 的默认安装包括一个 starter Vue.js 应用程序,以及 Webpack 和Laravel Mix。这些使用节点。

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

如果你不打算使用这些,你可以安全地删除node_modules、启动 Vue 应用程序和package.jsonLaravel 安装。

They have nothing to do with PHPStorm.

它们与 PHPStorm 无关。

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

编辑:在 Laravel 的最新版本中,该命令php artisan preset none将删除 Vue starter app

回答by Anand Mainali

When you install laravel you will got a folder called vendorin 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.

当你安装 laravel 时,你会在你的项目中得到一个名为vendor的文件夹。在这个文件夹中,你已经获得了 laravel 的所有pacakge 依赖项。所有这些包及其依赖项都列在composer.json 中

Same as node_modulesfolder 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.

node_modules文件夹相同,还包含与您的 javascript 项目相关的包依赖项。所以,你可以在你的项目中使用它。所有这些包及其依赖项都列在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 installwhen required.

在你的情况下,如果你没有使用 vue.js,react.js 那么你不需要运行npm install。您可以开始构建项目而无需担心 node_modules。您甚至可以删除此文件夹并在需要时使用npm install重新安装它。