Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

hooty's avatar
Level 1

npm install --production/npm run prod not working with devDependencies

Hello,

I'm currently trying to deploy my Laravel project to a live server (Forge/Envoyer setup). In the deployment hook I'm npm installing using:

npm install --production

so the devDependencies are ignored. However the next step fails:

npm run prod

with the error:

sh: 1: mix: not found

Moving laravel-mix out of devDependencies and into dependencies fixes this but then the next error I get is:

We couldn't find a supported version of Vue in your project. Please ensure that it's installed (npm install vue).

This is another package sitting in devDependencies. All of these packages were placed in devDependencies when I first created the Laravel project, and I confused why I have to move them all into dependencies to get them to work?

I could just run npm install without the --production tag but I didn't really want to install Cypress on my server. Here's my package.json:

{
    "private": true,
    "scripts": {
        "dev": "npm run development",
        "development": "mix",
        "watch": "mix watch",
        "watch-poll": "mix watch -- --watch-options-poll=1000",
        "hot": "mix watch --hot",
        "prod": "npm run production",
        "production": "mix --production"
    },
    "devDependencies": {
        "@inertiajs/inertia": "^0.3.6",
        "@inertiajs/inertia-vue": "^0.2.4",
        "@inertiajs/progress": "^0.1.2",
        "@tailwindcss/ui": "^0.1.3",
        "axios": "^0.21.1",
        "cypress": "^6.8.0",
        "laravel-jetstream": "^0.0.3",
        "laravel-mix": "^6.0.39",
        "lodash": "^4.17.19",
        "portal-vue": "^2.1.7",
        "postcss": "^8.4.4",
        "postcss-import": "^12.0.1",
        "resolve-url-loader": "^3.1.0",
        "tailwindcss": "^1.3.0",
        "vue": "^2.5.17",
        "vue-loader": "^15.9.8",
        "vue-template-compiler": "^2.6.12"
    },
    "dependencies": {
        "chart.js": "^3.5.1",
        "v-calendar": "^2.1.6"
    }
}

Thanks in advance :)

0 likes
3 replies
Sinnbeck's avatar

Move what you need to build from devDependencies to dependencies. Simple as that. So probably everything except cypress :)

If you compile on your local machine and push it to production using something like Lasso or a deployment pipeline, it makes sense to have it in devDependencies. Otherwise not.

hooty's avatar
Level 1

@Sinnbeck

Hi, yes that would probably be the easiest option. However I'm confused why Laravel automatically places these essential packages, such as 'laravel-mix' and 'vue', in "devDependencies" when you generate a new project rather than "dependencies". Thanks

Sinnbeck's avatar

@hooty My guess is that it assumes you have pipeline that installs and compiles it as part of this process on another server, and then moves the assets over. Thereby you don't put pressure on your precious production server.

Please or to participate in this conversation.