laravel-mix: __webpack_require__(...) is not a function
Laravel Mix Version: 1.4.2 Node Version : 8.0.0 NPM Version : 5.3.0 OS: Windows 10
Description:
I use code below when watch code:
mix.options({ extractVueStyles: true })
That error:
TypeError: webpack_require(…) is not a function
But when i run npm run dev, there is no error.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 15
It’s related to https://github.com/webpack/webpack/issues/5399 , workaround is to downgrade
extract-text-webpack-pluginfrom3.0.0to2.1.2.@ThomHurks Today, I edit my bootstrap.js file:
window.axios = require('axios')towindow.axios = require('axios/dist/axios.js')Now work well!
you can write
npm i --save extract-text-webpack-plugin@2.1.2oryarn add extract-text-webpack-plugin@2.1.2@JeffreyWay I’m a coworker of PimW and we attempted to debug this issue today. After we upgraded a project from Mix 0.12.1 to 1.4.2 this issue started to happen; npm run dev (or the first time you run npm run watch) works, but subsequent runs of npm run watch when you change a file always cause this error when you load your application.
Strange thing is that the error occurs in a Vue file which is shared with another project; that other project also uses Mix 1.4.2 and there it works just fine. We tried re-installing all node_modules, removing a whole bunch of CSS, using
scopedin the style tag in the Vue file in case there is some CSS conflict, and nothing worked. The only thing that solved it was simply going back to version 0.12.1 😦Something that may be of interest: the project that has the problem uses Pug in some templates (not in the file where the errors occurs though), and the project where the very same file does not cause any problems at all doesn’t use Pug, maybe that is related, but I’m unsure. It’s the only major “architectural” difference between the two projects I can think of.
Also, if you’re interested in our webpack.mix.js files: they’re exactly the same for both projects.
If we can do more to debug the issue, please let us know 😃