I can't run 'npm run dev' since Laravel updated with Vite

Stefan Izdrail

Founder & Senior Architect · 2026-06-29

Laravel Company
Title: Understanding 'npm run dev' Issues After Laravel Project Updates with Vite Taylor Otwell announced that new Laravel projects will run using Vite by default, but many users are encountering issues when trying to run the dev environment command npm run dev. This issue seems common after installing a fresh Laravel project and running 'npm install' followed by 'npm run dev'. You might be seeing errors like these: Error 1: error Error 2: localhost These errors indicate that your project is having trouble with the Vite configuration or package management. To fix this, follow these steps: 1. Check your package.json file for any inconsistencies or conflicting dependencies. Make sure it has the correct scripts and dependencies as shown below:
{
    "private": true,
    "scripts": {
        "dev": "vite",
        "build": "vite build && vite build --ssr"
    },
    "devDependencies": {
        "@inertiajs/inertia": "^0.11.0",
        "@inertiajs/inertia-vue3": "^0.6.0",
        "@inertiajs/progress": "^0.2.7",
        "@inertiajs/server": "^0.1.0",
        "@tailwindcss/forms": "^0.5.2",
        "@tailwindcss/typography": "^0.5.2",
        "@vitejs/plugin-vue": "^2.3.3",
        "@vue/server-renderer": "^3.2.31",
        "autoprefixer": "^10.4.7",
        "axios": "^0.25",
        "laravel-vite-plugin": "^0.2.1",
        "lodash": "^4.17.19",
        "postcss": "^8.4.14",
        "tailwindcss": "^3.1.0",
        "vite": "^2.9.11",
        "vue": "^3.2.31"
    }
}
2. Ensure your Laravel project has the latest versions of all dependencies installed and is compatible with Vite. Sometimes, conflicts between older or incompatible packages might cause issues. Run 'npm update' to ensure everything is up-to-date. 3. Check if you have the correct Vite configuration set up correctly for your Laravel project. If not, follow the official documentation on configuring Vite with Laravel. 4. Clear your local cache and try reinstalling the dependencies again. Use 'npm cache clean --force' or 'yarn cache clean' to clear your cache. Then run 'npm install' or 'yarn install'. 5. If you are using JetStream, ensure that all dependencies related to JetStream are updated accordingly. Additionally, check the documentation for any specific setup instructions for JetStream with Vite. 6. Try rebuilding your project using the 'build' script in your package.json file: 'npm run build' or 'yarn build'. If it succeeds, try running the dev environment again. 7. Consider opening a support ticket on Laravel's community channels like Discord or their forums if you are still facing issues. Provide relevant details about your setup, including any custom scripts, to help them troubleshoot the problem. By following these steps and ensuring correct dependency management and configuration, you should be able to successfully run 'npm run dev' in your Laravel project. Remember to test your applications on a staging environment before deploying to production to ensure stability and smooth development workflow.