simple way to include node_modules in laravel 5.5

Stefan Bogdanescu

Founder & Senior Architect · 2026-06-29

Laravel Company
# The Right Way to Handle `node_modules` in Laravel 5.5: Mastering Asset Bundling As developers working with older frameworks like Laravel 5.5, one of the common stumbling blocks is integrating third-party npm packages—the contents of the `node_modules` directory—into the final application build. You correctly identified a common issue: installing packages like Moment.js and trying to reference them directly in your HTML scripts results in errors because the server environment (PHP/Blade) does not understand the Node dependency structure. This post will dive into why direct inclusion fails, and more importantly, show you the correct, modern approach using asset management tools like Laravel Mix to properly integrate dependencies. ## Why Direct Inclusion Fails When you run `npm install angular-moment moment --save`, Node creates a `node_modules` directory containing the actual source code for those libraries. While this is essential for development, attempting to reference files directly via paths like `