Laravel Mix编译资源后还需要node_modules文件夹吗?

Is node_modules folder still needed after Laravel Mix compiled the assets?

node_modules 文件夹很大。 Laravel Mix compile everything 后能不能删除?当然,我之前尝试过(安装 jquery),然后在 Laravel Mix 编译所有内容后删除 node_modules 文件夹。我的 jquery 代码仍然 运行 并且完全没有错误。那还好吗?

是的,您可以在 运行:

之后删除它
npm run production

在 运行 这个命令之后所有必要的代码将保存在 app.js

需要时 node_modules 您可以使用 :

再次下载它们
npm install

永远不要将 node_modules 文件夹提交给 git。那会花很长时间。只需提交 package.jsonpackage-lock.json.

但是,您不希望每次构建代码时都必须重新安装它们。我检查了一个大项目,总大小为310 M。在什么情况下您无法保持原样?

为了直接回答您的问题,Laravel 永远不会 运行 来自 node_modules 文件夹的代码,所有代码都从那里使用被编译成app.js,所以如果你不得不删除是安全的。