Vue CLI build fails with transpileDependencies.map is not a function
npm error transpileDependencies.map is not a functionShort answer
The option accepts true or false only in Vue CLI 5 and later. An older Babel plugin expects an array and calls .map on it, so a boolean breaks the build. Upgrade the Vue CLI packages together with vue upgrade, or list the dependencies in an array. Any other value type fails the same way.
Fix it fast
1Find out which cause you have
Read the option in vue.config.js and the installed versions of the Vue CLI packages.
grep -n "transpileDependencies" vue.config.js npm ls @vue/cli-service @vue/cli-plugin-babel2Match what you see, then jump to its fix
What does the error look like?
npm error transpileDependencies.map is not a functionTypeError: transpileDependencies.map is not a function
Cause 1 of 2
A boolean is set but the Vue CLI packages are older than 5
1Check
The v4 to v5 migration guide says the option now accepts a boolean in v5.
npm ls @vue/cli-service2Fix
Upgrade the project's Vue CLI packages. Or keep your version and list the packages to transpile in an array.
vue upgrade
# or, staying on the old version:
module.exports = {
transpileDependencies: ['my-dep', /other-dep/],
}3Verify
The build starts.
npm run buildConfirmed by cli.vuejs.org
Cause 2 of 2
The value is not a boolean or an array
1Check
The reference says the type is boolean or an array of strings and regular expressions.
grep -n -A3 "transpileDependencies" vue.config.js2Fix
Use true, false, or an array.
module.exports = {
transpileDependencies: ['my-dep'],
}3Verify
Run the build again.
npm run buildConfirmed by cli.vuejs.org
How do I stop it coming back?
- Upgrade all @vue/cli-* packages together, never one at a time.
- Transpile only the dependencies that need it, since transpiling everything slows the build.
- New projects should start from create-vue; Vue CLI is in maintenance mode.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
ng serve says it cannot determine the project or target
Cannot determine project for command.
The Angular CLI looked through angular.json for a project that defines the target you asked for (serve, build, test) and found none, or found several and could not pick one.
3 causes, each with a fixBack end
ng fails with Cannot find module @angular/cli/bin/ng
Cannot find module '@angular/cli/bin/ng'
The ng command is the entry point to the Angular CLI package.
2 causes, each with a fixBack end
Angular app shows 'Cannot GET /' when served by a Node.js server
Cannot GET /dashboard
Cannot GET / is Express saying no route or file matches the request.
3 causes, each with a fixBack end
ng serve cannot find the dev-server builder package
Could not find the implementation for builder @angular/build:dev-server
The builder named in angular.json (for example @angular-devkit/build-angular:dev-server) is looked up as an npm package starting from the workspace root.
3 causes, each with a fixBack end
Angular build says it cannot resolve '@angular/localize/init'
Can't resolve '@angular/localize/init' in '/usr/src/app/src'
The build imports @angular/localize, and that package is not in node_modules.
2 causes, each with a fixBack end
The command npm run build -- --prod exited with code 1 (Angular)
The command "npm run build -- --prod" exited with code 1
Exit code 1 only says the build failed; the real message is above it.
2 causes, each with a fix