Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

Vue CLI build fails with transpileDependencies.map is not a function

Errornpm error transpileDependencies.map is not a function

Short 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.

  • Applies to Vue CLI 4 and 5, Node.js 22
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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-babel
  2. 2Match what you see, then jump to its fix

    1. 1vue.config.js has transpileDependencies: true and npm ls shows version 4.x.A boolean is set but the Vue CLI packages are older than 5Fix
    2. 2The option holds a string, an object or the result of a function.The value is not a boolean or an arrayFix

What does the error look like?

  • npm error transpileDependencies.map is not a function
  • TypeError: 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-service

2Fix

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 build

Confirmed by cli.vuejs.org

Did this fix it?

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.js

2Fix

Use true, false, or an array.

module.exports = {
  transpileDependencies: ['my-dep'],
}

3Verify

Run the build again.

npm run build

Confirmed by cli.vuejs.org

Did this fix it?

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 fix

Back 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 fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.