Laravel app.js Not Found and NPM Run Failed in New Project: Troubleshooting Guide

Abstract: Resolve Laravel app.js not found and npm run failed errors by verifying build tool configuration, clearing caches, and ensuring correct dependency installation.

Created: 2026-09-02 by
Laravel’s build tools often fail to locate app.js or throw npm errors in fresh installations due to missing dependencies, incorrect manifest paths, or version mismatches between Vite and Mix. This guide resolves these specific compilation failures by verifying your package structure, clearing caches, and ensuring your environment matches the Laravel version you are running.

Understanding Build Tool Evolution in Laravel

The confusion surrounding app.js not found typically stems from the transition between Laravel Mix and Vite. Older Laravel versions (prior to 9) relied on Webpack via Laravel Mix. Newer versions default to Vite for faster, more modern asset compilation. If you are seeing references to mix.mix, it is a typo; the correct helper function is mix() in Mix projects or vite() in Vite projects. Identifying which tool your project uses is the first critical step in troubleshooting. In a standard Laravel 10+ installation, the resources/js/app.js file is compiled into public/build/manifest.json. If this manifest is missing or corrupted, the application cannot locate the JavaScript assets. Conversely, in legacy projects using Mix, the output is usually public/js/app.js. Mixing up these paths leads to the "not found" error during runtime. For broader context on resolving general npm issues that might underlie these specific framework problems, see our guide on Troubleshooting npm Errors in Node.js for Beginners.

Verifying Dependencies and Installation

Before diving into configuration files, ensure that all necessary packages are installed. A common cause of failure is an incomplete npm install or yarn install process. Always run the installation command from the root directory of your Laravel project.
  • Navigate to your project root in the terminal.
  • Run npm install to install all dependencies listed in package.json.
  • If you use Yarn, run yarn install instead.
  • Check for any peer dependency warnings or errors in the terminal output.
If the installation fails, check your Node.js version. Laravel generally requires Node.js version 14 or higher. You can verify your version by running node -v. If your version is outdated, consider using a version manager like nvm to switch to a compatible release. This ensures that native modules compile correctly against your system libraries.

Configuring Vite for Modern Laravel Projects

For Laravel 9 and above, Vite is the default build tool. The configuration resides in vite.config.js. Ensure that the base path is correctly set. By default, it should be '' or '/' depending on your deployment subdirectory. Open vite.config.js and verify the following settings:
export default defineConfig({
    plugins: [
        laravel({
            input: ['resources/css/app.css', 'resources/js/app.js'],
            refresh: true,
        }),
    ],
});
If the input array does not point to resources/js/app.js, Vite will not compile your entry point. After verifying the config, clear the cache and rebuild the assets. Run npm run dev for development or npm run build for production. If the build succeeds, check the public/build directory to confirm that manifest.json and the JS bundle exist.

Configuring Laravel Mix for Legacy Projects

If you are maintaining an older Laravel project that still uses Mix, the setup differs slightly. The configuration is located in webpack.mix.js. Ensure that your mix call includes the correct paths.
mix.js('resources/js/app.js', 'public/js')
   .sass('resources/sass/app.scss', 'public/css');
Notice that the output directory is public/js. Your Blade templates must reference this exact path using the mix() helper. If you recently upgraded Laravel but kept the old Mix configuration, ensure that your package.json scripts are updated to reflect the correct commands, such as npm run watch or npm run prod.

Clearing Caches and Resolving Path Issues

Sometimes the code is correct, but cached data prevents the application from reflecting changes. Laravel caches configuration and view files, which can lead to stale asset references.
  • Clear the config cache with php artisan config:clear.
  • Clear the route cache with php artisan route:clear.
  • Clear the view cache with php artisan view:clear.
  • Remove the public/build directory manually if you suspect corruption in the Vite manifest.
  • Restart your local server or development environment.
Additionally, check your Blade templates. In Vite projects, you must use the @vite directive rather than {{ mix() }}. Using the wrong directive in a Vite-enabled project will result in broken asset links. For example:
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
    <head>
        @vite(['resources/css/app.css', 'resources/js/app.js'])
    </head>
    <body>
        ...
    </body>
</html>
Using {{ mix() }} in this context will look for the old Mix manifest structure, causing the "not found" error. Ensure consistency between your build tool configuration and your template directives.

Frequently Asked Questions

Why is my public/build folder empty after npm run build?

This usually indicates that Vite encountered an error during compilation but did not display it prominently. Check your terminal output for syntax errors in your JavaScript files or missing imports. Ensuring your vite.config.js points to existing source files is essential for generating the output.

Can I switch from Vite back to Laravel Mix in a new project?

While technically possible, it is not recommended for new projects as Vite is the current standard. Switching requires uninstalling Vite packages, installing Laravel Mix dependencies, and rewriting your package.json scripts and webpack.mix.js configuration. It adds unnecessary complexity without providing performance benefits over Vite.

What causes "Module not found: Can't resolve '@vue/compiler-sfc'"?

This error occurs when Vue-specific dependencies are missing from your node_modules folder. Running npm install again typically resolves this. If the issue persists, delete the node_modules folder and package-lock.json file, then reinstall all dependencies to ensure a clean state.

How do I debug why npm run dev fails silently?

Add the --verbose flag to your command, such as npm run dev --verbose. This provides detailed logging about which plugin or loader is failing. Additionally, check if any other processes are using port 5173, which is the default Vite server port, as conflicts here can cause silent failures.

Is it safe to ignore npm audit warnings during installation?

It is generally safe to proceed with development despite low-severity warnings, as they often relate to indirect dependencies that do not affect functionality. However, high-severity security vulnerabilities should always be addressed. Use npm audit fix to automatically resolve fixable issues before deploying to production.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More