{"id":20180,"library":"laravel-mix-transpile-node-modules","title":"Laravel Mix Transpile Node Modules","description":"Laravel Mix extension for transpiling JavaScript dependencies inside node_modules with Babel. Current stable version is 2.0.4, compatible with Mix v4, v5, and v6. It selectively applies Babel transformations to problematic npm packages that fail to compile under the default webpack `exclude` rule for node_modules. Differentiator: no manual webpack config needed — simply call `mix.transpileNodeModules()` in your `webpack.mix.js` file. Actively maintained, latest updates fix Windows path issues and babel-loader detection.","status":"active","version":"2.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/daun/laravel-mix-transpile-node-modules","tags":["javascript","laravel-mix","babel","transpile","transpilation","node_modules","node"],"install":[{"cmd":"npm install laravel-mix-transpile-node-modules","lang":"bash","label":"npm"},{"cmd":"yarn add laravel-mix-transpile-node-modules","lang":"bash","label":"yarn"},{"cmd":"pnpm add laravel-mix-transpile-node-modules","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; required to hook into the Mix webpack chain.","package":"laravel-mix","optional":false}],"imports":[{"note":"This package is designed for Laravel Mix's CommonJS environment; ES module imports are not supported.","wrong":"import 'laravel-mix-transpile-node-modules'","symbol":"transpileNodeModules","correct":"require('laravel-mix-transpile-node-modules')"},{"note":"The package registers itself as a mix extension via side effect; it exports no symbols.","wrong":"const Transpile = require('laravel-mix-transpile-node-modules').default","symbol":"laravel-mix-transpile-node-modules","correct":"require('laravel-mix-transpile-node-modules')"},{"note":"Calling it unconditionally may cause unnecessary transpilation in development; best practice is to conditionally call it for production builds.","wrong":"mix.transpileNodeModules();","symbol":"mix.transpileNodeModules","correct":"if (mix.inProduction()) { mix.transpileNodeModules() }"}],"quickstart":{"code":"// webpack.mix.js\nconst mix = require('laravel-mix');\nrequire('laravel-mix-transpile-node-modules');\n\nmix.js('resources/js/app.js', 'public/js');\n\nif (mix.inProduction()) {\n  mix.transpileNodeModules();\n}\n","lang":"javascript","description":"Registers the extension and conditionally transpiles all node_modules in production builds."},"warnings":[{"fix":"Update to v2.0.3+.","message":"Previously, babel-loader detection failed on Windows due to path separator mismatch. Fixed in v2.0.3.","severity":"gotcha","affected_versions":"<=2.0.2"},{"fix":"Update to v2.0.4+.","message":"Empty webpack rule tests caused errors. Fixed in v2.0.4.","severity":"gotcha","affected_versions":"<=2.0.3"},{"fix":"Upgrade Laravel Mix to v4+ or stay on v1.x of this package.","message":"Version 2.0.0 dropped support for Mix v3. Only v4, v5, and v6 are supported.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Pass only the problematic packages: mix.transpileNodeModules(['swiper', 'dom7']).","message":"Transpiling all node_modules can significantly increase build times. Use selective transpilation with array of module names when possible.","severity":"gotcha","affected_versions":"all"},{"fix":"Wrap the call in a production check: if (mix.inProduction()) { mix.transpileNodeModules() }.","message":"Calling mix.transpileNodeModules() in development may cause performance issues if many modules are transpiled.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run: npm install laravel-mix-transpile-node-modules --save-dev","cause":"Package not installed or missing from package.json.","error":"Error: Cannot find module 'laravel-mix-transpile-node-modules'"},{"fix":"Add require('laravel-mix-transpile-node-modules') at the top of your webpack.mix.js.","cause":"require('laravel-mix-transpile-node-modules') not called before usage.","error":"TypeError: mix.transpileNodeModules is not a function"},{"fix":"Install babel-loader: npm install babel-loader --save-dev","cause":"babel-loader is not installed in the project.","error":"Error: No babel-loader found. Make sure babel-loader is installed."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}