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

GodziLaravel's avatar

"npm run prod" returns : Error Cannot find module webpack.mix

Hello,

I try npm run prod but it's not working !

Error: Cannot find module '/data/www/(...).com/webpack.mix'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (/data/www/(...).com/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at Object.<anonymous> (/data/www/(...).com/node_modules/laravel-mix/setup/webpack.config.js:12:1)
    at Module._compile (/data/www/(...).com/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (/data/www/(...).com/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at WEBPACK_OPTIONS (/data/www/(...).com/node_modules/webpack-cli/bin/utils/convert-argv.js:114:13)
    at requireConfig (/data/www/(...).com/node_modules/webpack-cli/bin/utils/convert-argv.js:116:6)
    at /data/www/(...).com/node_modules/webpack-cli/bin/utils/convert-argv.js:123:17
    at Array.forEach (<anonymous>)
    at module.exports (/data/www/(...).com/node_modules/webpack-cli/bin/utils/convert-argv.js:121:15)
    at yargs.parse (/data/www/(...).com/node_modules/webpack-cli/bin/cli.js:71:45)
    at Object.parse (/data/www/(...).com/node_modules/webpack-cli/node_modules/yargs/yargs.js:576:18)
    at /data/www/(...).com/node_modules/webpack-cli/bin/cli.js:49:8
    at Object.<anonymous> (/data/www/(...).com/node_modules/webpack-cli/bin/cli.js:366:3)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at runCli (/data/www/(...).com/node_modules/webpack/bin/webpack.js:54:2)
    at Object.<anonymous> (/data/www/(...).com/node_modules/webpack/bin/webpack.js:147:2)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)

I deleted the node_modules then npm install but always the same error.

0 likes
13 replies
GodziLaravel's avatar

@sinnbeck yes

{
    "private": true,
    "scripts": {
        "dev": "npm run development",
        "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
        "watch": "npm run development -- --watch",
        "watch-poll": "npm run watch -- --watch-poll",
        "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
        "prod": "npm run production",
        "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
    },
    "devDependencies": {
        "axios": "^0.19.2",
        "bootstrap": "^4.1.0",
        "browser-sync": "^2.26.7",
        "browser-sync-webpack-plugin": "^2.0.1",
        "cross-env": "^5.2.1",
        "jquery": "^3.2",
        "laravel-mix": "^4.1.4",
        "lodash": "^4.17.5",
        "popper.js": "^1.16.1",
        "resolve-url-loader": "^2.3.1",
        "sass": "^1.26.3",
        "sass-loader": "^7.3.1",
        "vue": "^2.5.17",
        "vue-template-compiler": "^2.6.10"
    },
    "dependencies": {
        "@babel/polyfill": "^7.8.7",
        "@coreui/coreui": "^2.1.12",
        "@coreui/coreui-plugin-chartjs-custom-tooltips": "^1.3.1",
        "@coreui/coreui-pro": "^2.1.14",
        "@coreui/icons": "^0.3.0",
        "@coreui/vue": "^2.1.2",
        "@fortawesome/fontawesome-free": "^5.12.1",
        "bootstrap": "^4.3.1",
        "bootstrap-vue": "2.0.0-rc.24",
        "chart.js": "^2.8.0",
        "colorette": "^1.2.1",
        "core-js": "^2.6.9",
        "css-vars-ponyfill": "^2.2.1",
        "daterangepicker": "^3.0.5",
        "flag-icon-css": "^3.4.6",
        "font-awesome": "^4.7.0",
        "mini-toastr": "0.6.6",
        "moment-business-days": "^1.1.3",
        "perfect-scrollbar": "^1.4.0",
        "quill": "^1.3.7",
        "simple-line-icons": "^2.4.1",
        "spinkit": "1.2.5",
        "text-mask-addons": "^3.8.0",
        "v-calendar": "^0.9.7",
        "v-tooltip": "^2.0.2",
        "vue": "^2.6.10",
        "vue-bootstrap-datetimepicker": "^5.0.1",
        "vue-chartjs": "^3.4.2",
        "vue-clipboard2": "^0.3.1",
        "vue-codemirror": "^4.0.6",
        "vue-form-wizard": "^0.8.4",
        "vue-grid-layout": "^2.3.6",
        "vue-i18n": "^8.17.4",
        "vue-light-timeline": "^1.0.3",
        "vue-loading-overlay": "^3.4.2",
        "vue-moment": "^4.0.0",
        "vue-mq": "^1.0.1",
        "vue-multiselect": "^2.1.6",
        "vue-notifications": "0.9.0",
        "vue-perfect-scrollbar": "^0.1.0",
        "vue-quill-editor": "^3.0.6",
        "vue-resize": "^0.4.5",
        "vue-router": "^3.1.6",
        "vue-select": "2.4.0",
        "vue-simple-calendar": "^3.0.2",
        "vue-slider-component": "^3.1.1",
        "vue-star-rating": "^1.6.1",
        "vue-switches": "^2.0.1",
        "vue-tables-2": "^1.6.25",
        "vue-text-mask": "^6.1.2",
        "vue-tippy": "^4.4.0",
        "vue-toasted": "^1.1.27",
        "vue2-google-maps": "^0.10.6",
        "vuedraggable": "^2.23.2",
        "vuejs-datepicker": "^1.6.2",
        "vuelidate": "^0.7.4"
    }
}

GodziLaravel's avatar

@sinnbeck I had this problem when I added /public/js and /public/css to gitIgnor then I did git rm -rf --cached . on the local side

Sinnbeck's avatar

So there is no webpack.mix.js file in the root directory?

Sinnbeck's avatar

Sorry a bit confused. It exists locally but not on production server?

Sinnbeck's avatar

Ok. Can you show your gitignore file? My guess is that you have added the file there by accident, which will cause it to be removed from production

GodziLaravel's avatar
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.testing
.env.backup
.phpunit.result.cache
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
webpack.mix.js
.idea/
/public/img/avatars

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

Remove webpack.mix.js from the gitignore file :) It should be in gits control

Then try running git add webpack.mix.jsand then git status. If it has picked up the file, you can commit, push, pull and try again :)

Sinnbeck's avatar

Happy to help. It can happen for all of us :)

1 like

Please or to participate in this conversation.