TypeError:(0,_ignore.getFileExtensions)不是一个函数

时间:2019-04-13 11:47:47

标签: vue.js vue-cli vue-cli-3

Vue CLI v3.5.5

我安装了vue-cli,并通过create命令创建了一个新项目,但是最后我遇到了一个错误。我该怎么办?

? Please pick a preset: Manually select features

? Check the features needed for your project: Babel, Router, Linter

? Use history mode for router? (Requires proper server setup for index fallback in production) Yes

? Pick a linter / formatter config: Airbnb

? Pick additional lint features: (Press <space> to select, <a> to toggle all, <i> to invert selection)Lint on save

? Where do you prefer placing config for Babel, PostCSS, ESLint, etc.? In package.json

? Save this as a preset for future projects? No

? Pick the package manager to use when installing dependencies: Yarn

 ERROR  TypeError: (0 , _ignore.getFileExtensions) is not a function
Occurred while linting /Users/untca/Sites/vue-flickr/src/main.js:2
TypeError: (0 , _ignore.getFileExtensions) is not a function
Occurred while linting /Users/untca/Sites/vue-flickr/src/main.js:2

at checkSourceValue (/Users/untca/Sites/vue-flickr/node_modules/eslint-plugin-import/lib/rules/no-useless-path-segments.js:103:60)
    at checkSourceValue (/Users/untca/Sites/vue-flickr/node_modules/eslint-module-utils/moduleVisitor.js:29:5)
    at checkSource (/Users/untca/Sites/vue-flickr/node_modules/eslint-module-utils/moduleVisitor.js:34:5)
    at listeners.(anonymous function).forEach.listener (/Users/untca/Sites/vue-flickr/node_modules/eslint/lib/util/safe-emitter.js:45:58)
    at Array.forEach (<anonymous>)
    at Object.emit (/Users/untca/Sites/vue-flickr/node_modules/eslint/lib/util/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/Users/untca/Sites/vue-flickr/node_modules/eslint/lib/util/node-event-generator.js:251:26)
    at NodeEventGenerator.applySelectors (/Users/untca/Sites/vue-flickr/node_modules/eslint/lib/util/node-event-generator.js:280:22)
    at NodeEventGenerator.enterNode (/Users/untca/Sites/vue-flickr/node_modules/eslint/lib/util/node-event-generator.js:294:14)
    at CodePathAnalyzer.enterNode (/Users/untca/Sites/vue-flickr/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:632:23)

1 个答案:

答案 0 :(得分:0)

使用airbnb规则(eslint-plugin-import#1322)时,上游ESLint插件存在一个已知问题。 workaround将添加一个禁用插件使用的ESLint规则:

// .eslintrc.js
module.exports = {
  rules: {
    "import/no-useless-path-segments": "off", // add this rule
  },
};