vue-cli: Cannot read property 'android' of undefined

Version

3.7.0

Environment info

mac

Steps to reproduce

['@vue/app', {
  polyfills: [
    // all polyfills list -> https://github.com/zloirock/core-js
    'es6.object.assign',
    'es6.array.find',
    'es6.array.iterator',
    'es6.function.name',
    'es7.object.values',
    'web.dom.iterable'
  ]

It seem caused by’web.dom.iterable’

What is expected?

build is running

What is actually happening?

Cannot read property ‘android’ of undefined

['@vue/app', {
  polyfills: [
    // all polyfills list -> https://github.com/zloirock/core-js
    'es6.object.assign',
    'es6.array.find',
    'es6.array.iterator',
    'es6.function.name',
    'es7.object.values',
    'web.dom.iterable'
  ]

It seem caused by’web.dom.iterable’

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 5
  • Comments: 17 (4 by maintainers)

Most upvoted comments

Updating my babel.config.js fixed this issue for me:

module.exports = {
  presets: [["@vue/cli-plugin-babel/preset", {
    useBuiltIns: "usage",
    polyfills: [
      // module filenames from .\node_modules\core-js\modules\
      'es.promise',  // before "es6.promise"
      'es.symbol',  // before "es6.symbol"
    ],
  }]]
}

Hi, encountered the same issue with any polyfill starting with es.* or web.* looks like @vue\babel-preset-app\index.js (v3.8) is getting a list of polyfills from

const builtInsList = require('@babel/preset-env/data/built-ins.json')

(I have @babel/preset-env@7.3.4) then includes contains "web.dom.iterable" which is not in builtInsList

  return includes.filter(item => {
    return isPluginRequired(builtInTargets, builtInsList[item])
  })

builtInsList[item] is undefined which later throws an exception. So it looks like only keys from this file will work

I can see that it has changed in the recent version of vue-cli and babel-env.

I have this error (I will update versions on my project)

Module build failed (from ./node_modules/babel-loader/lib/index.js): TypeError: [BABEL] /code/frontend/src/main.js: Cannot read property ‘android’ of undefined (While processing: “node_modules/@vue/babel-preset-app/index.js”)

package.json "dependencies": { "vue": "2.6.10", "vue-moment": "^4.1.0", "vue-router": "3.0.7", "vuex": "3.1.1", "vuex-persist": "2.0.1" }

and "devDependencies": { "@babel/core": "^7.4.5", "@vue/cli-plugin-babel": "^4.1.1", "@vue/cli-plugin-eslint": "^4.1.1", "@vue/cli-plugin-unit-jest": "^4.1.1", "@vue/cli-service": "^4.1.1", "@vue/eslint-config-airbnb": "^4.0.0", "@vue/test-utils": "^1.0.0-beta.29", "audit-ci": "^1.4.1", "auditjs": "^3.1.1", "babel-core": "7.0.0-bridge.0", "babel-eslint": "^10.0.1", "babel-jest": "^25.1.0", "eslint": "^5.15.3", "eslint-plugin-vue": "^5.2.2", "node-sass": "^4.11.0", "sass-loader": "^7.1.0", "vue-svg-loader": "^0.12.0", "vue-template-compiler": "^2.6.10", "webpack": "^4.33.0", "webpack-dev-server": "^3.3.1" }

babel.config.js

module.exports = {
  presets: [
    ['@vue/app', {
      polyfills: [
        'es6.array.iterator',
        'es6.object.assign',
        'es6.promise',
        'es6.regexp.constructor',
        'es6.regexp.flags',
        'es6.regexp.match',
        'es7.promise.finally',
      ],
    }],
  ],
  plugins: ['@babel/plugin-proposal-optional-chaining'],
};

it happened after I use: yarn upgrade-interactive

Got this working by reinstalling @vue/cli npm install -g @vue/cli.

babel.config.js

module.exports = {
  presets: [['@vue/cli-plugin-babel/preset', {
    polyfills: [
      // modules you can find here: https://github.com/zloirock/core-js
      'es.string.starts-with',
      'web.url-search-params'
    ],
  }]],
};

@jhildings Did you add core-js@3? Vue CLI v3 is only compatible with core-js@2