metafizzy / packery

:bento: Gapless, draggable grid layouts
https://packery.metafizzy.co
4.13k stars 315 forks source link

laravel mix/webpack ERROR Module not found: Error: Can't resolve 'jquery' #553

Open jayenne opened 3 years ago

jayenne commented 3 years ago

Hi, I'm using a clean Laravel install and using Packery with vanilla Javascript (sans Jquery). It works perfectly using a cdn include but when I replace that script with an NPM require if fails:

ERROR in ./node_modules/packery/dist/packery.pkgd.min.js Module not found: Error: Can't resolve 'jquery' in '/var/www/jetstream/node_modules/packery/dist'

I simply install via NPM then add mix.js('node_modules/packery/dist/packery.pkgd.min.js','public/js') to my webpack.mix.js When I npm run dev it fails with the error above.

Is this to be expected? Do I really need jQuery for it to compile?

Thanks.

desandro commented 3 years ago

You do not need jQuery to compile. The issue is likely that package.pkgd.min.js includes jquery-bridget which does require jQuery. Instead, I recommend you require the source file node_modules/packery/js/packery, rather than the dist file.

jayenne commented 3 years ago

Brilliant. Thank you.

On 24 Jan 2021, at 03:32, David DeSandro notifications@github.com wrote:



You do not need jQuery to compile. The issue is likely that package.pkgd.min.js includes jquery-bridget which does require jQuery. Instead, I recommend you require the source file node_modules/packery/js/packery, rather than the dist file.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmetafizzy%2Fpackery%2Fissues%2F553%23issuecomment-766285036&data=04%7C01%7C%7Cd70c4e9c6b5b47ee4b1f08d8c0189cf9%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637470559227027150%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=OzGZPPHkHRMuJ%2FBrLjz3NMRixoLlDcuFDu8YCJRneGU%3D&reserved=0, or unsubscribehttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAB2SL46ENAYJRP46VTLBX5DS3OIDBANCNFSM4WOPTXAA&data=04%7C01%7C%7Cd70c4e9c6b5b47ee4b1f08d8c0189cf9%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637470559227027150%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=RT40Yt8mD5E%2BK5Cv1qWAGYmo3PZOeG0g%2Frhy5%2BUpzAI%3D&reserved=0.