[英]Is node_modules folder still needed after Laravel Mix compiled the assets?
node_modules
folder is quite large in term of size. node_modules
文件夹的大小很大。 I wonder if we can delete it after Laravel Mix compile everything? 我想知道Laravel Mix编译完所有内容后是否可以删除它? Sure, I tried it before (install
jquery
) and then delete node_modules folder after Laravel Mix compiled everything. 当然,我之前尝试过(安装
jquery
),然后在Laravel Mix编译所有内容后删除了node_modules文件夹。 My jquery
code still running and there's no error at all. 我的
jquery
代码仍在运行,完全没有错误。 So is it okay? 这样可以吗
You should never commit your node_modules
folder to git. 您永远不要将
node_modules
文件夹提交给git。 That would take forever. 那将永远。 Just commit
package.json
and package-lock.json
. 只需提交
package.json
和package-lock.json
。
However, you wouldn't want to have to re-install them everytime you build your code. 但是,您不需要在每次构建代码时都重新安装它们。 I checked a large project and the total size is
310 M
. 我检查了一个大项目,总大小为
310 M
What situation do you have where you can't keep that in place? 您在什么情况下无法保持原样?
To directly answer your question, Laravel will never run code from the node_modules
folder, all of the code used from there is compiled into app.js
, so it is safe to delete if you had to. 为了直接回答您的问题,Laravel 永远不会运行来自
node_modules
文件夹的代码,从那里使用的所有代码都编译到app.js
,因此,如果必须的话,可以安全地删除。
yes, you can remove it after run: 是的,您可以在运行后将其删除:
npm run production
after run this command all necessary codes will save in app.js 运行此命令后,所有必要的代码将保存在app.js中
and when need node_modules you can download them again with : 当需要node_modules时,可以使用以下命令再次下载它们:
npm install
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.