简体   繁体   English

如何将 node_modules 中的插件添加到 Laravel mix

[英]How to add plugins from node_modules to Laravel mix

Here is my code这是我的代码

   mix.js([
        'node_modules/chocolat/dist/js/jquery.chocolat.js',
        'node_modules/textcounter/jquery.textcounter.js',
        'node_modules/foundation-sites/dist/js/foundation.js',
        'node_modules/owl.carousel/dist/owl.carousel.js',
        'resources/assets/js/jquery.fileuploader.min.js',
        'resources/assets/js/app.js',
    ], 'public/js/all.js', './');

And I get error that jQuery is not defined.我收到未定义 jQuery 的错误。 I have downloaded it, it is 100% there.我已经下载了它,它是 100% 那里。

In the example provided in the github repo you can see how it normally is included.在 github 存储库中提供的示例中,您可以看到它通常是如何包含的。 Check this file: resources\\assets\\js\\bootstrap.js检查这个文件: resources\\assets\\js\\bootstrap.js

You should update your webpack file.你应该更新你的 webpack 文件。 You didn't include the vanilla jquery in your array.您没有在数组中包含 vanilla jquery。 You should do that as the first item in the array.您应该将其作为数组中的第一项。 Also, if you just want to concatinate scripts you should use the scripts() method instead of the js() method.此外,如果您只想连接脚本,您应该使用scripts()方法而不是js()方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM