{"record":{"id":"9b1976d7d5fc9b18","repo":"vuejs/vue-cli","slug":"transpiledependencies-only-accepts-an-array-of-str","errorCode":null,"errorMessage":"transpileDependencies only accepts an array of string or regular expressions","messagePattern":"transpileDependencies only accepts an array of string or regular expressions","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@vue/cli-plugin-babel/index.js","lineNumber":16,"sourceCode":"const path = require('path')\nconst babel = require('@babel/core')\nconst { isWindows } = require('@vue/cli-shared-utils')\n\nfunction getDepPathRegex (dependencies) {\n  const deps = dependencies.map(dep => {\n    if (typeof dep === 'string') {\n      const depPath = path.join('node_modules', dep, '/')\n      return isWindows\n        ? depPath.replace(/\\\\/g, '\\\\\\\\') // double escape for windows style path\n        : depPath\n    } else if (dep instanceof RegExp) {\n      return dep.source\n    }\n\n    throw new Error('transpileDependencies only accepts an array of string or regular expressions')\n  })\n  return deps.length ? new RegExp(deps.join('|')) : null\n}\n\n/** @type {import('@vue/cli-service').ServicePlugin} */\nmodule.exports = (api, options) => {\n  const useThreads = process.env.NODE_ENV === 'production' && !!options.parallel\n  const cliServicePath = path.dirname(require.resolve('@vue/cli-service'))\n\n  // try to load the project babel config;\n  // if the default preset is used,\n  // there will be a VUE_CLI_TRANSPILE_BABEL_RUNTIME env var set.\n  // the `filename` field is required\n  // in case there're filename-related options like `ignore` in the user config\n  babel.loadPartialConfigSync({ filename: api.resolve('src/main.js') })\n\n  api.chainWebpack(webpackConfig => {\n    webpackConfig.resolveLoader.modules.prepend(path.join(__dirname, 'node_modules'))","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/vuejs/vue-cli/blob/7eb93c169c7520935252e2473387f923ef80d856/packages/@vue/cli-plugin-babel/index.js#L1-L34","documentation":"cli-plugin-babel's getDepPathRegex() builds one combined RegExp from the `transpileDependencies` array so the babel loader can decide which node_modules to run through. Each entry is either turned into a `node_modules/<name>/` path (string) or its `.source` is read (RegExp). Any other JS type cannot be converted into a matcher, so the function rejects the whole array.","triggerScenarios":"Setting `transpileDependencies` in vue.config.js to an array containing a non-string, non-RegExp value: a number, object, array, boolean, null, or a function.","commonSituations":"Passing a glob/minimatch object instead of a string; passing a function expecting it to be called; a numeric config copied from elsewhere; YAML/auto-generated config producing a non-string scalar.","solutions":["Make every entry a string package name (e.g. `'my-lib'`) or a RegExp literal (e.g. `/my-lib/`).","If you wanted a pattern, express it as a RegExp rather than an object.","Remove the offending non-conforming entry from the array."],"exampleFix":"// vue.config.js — before\nmodule.exports = { transpileDependencies: ['my-lib', 42, { name: 'other' }] }\n// after\nmodule.exports = { transpileDependencies: ['my-lib', /other/] }","handlingStrategy":"type-guard","validationCode":"const deps = config.transpileDependencies || []\nconst bad = deps.filter(d => typeof d !== 'string' && !(d instanceof RegExp))\nif (bad.length) throw new Error(`transpileDependencies entries must be string|RegExp: ${JSON.stringify(bad)}`)","typeGuard":"const isTranspileDep = (d) => typeof d === 'string' || d instanceof RegExp\nconst allValid = deps.every(isTranspileDep)","tryCatchPattern":null,"preventionTips":["Lint vue.config.js so `transpileDependencies` is `Array<string|RegExp>`.","Use RegExp literals for patterns instead of glob objects."],"tags":["babel","configuration","transpile","type-validation"],"backgroundTag":null,"analyzedSha":"7eb93c169c7520935252e2473387f923ef80d856","analyzedAt":"2026-08-13T10:13:37.803Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}