碰到了一个问题: vscode 中报错: eslint cannot find module ‘babel-eslint’

首先说, 我的.eslintrc.js:

module.exports = {
	extends: ['wind/node'],
	globals: {
		FileReader: false,
		DOMException: false,
		Headers: false,
		fetch: false,
	},
	// parserOptions: {
	//   ecmaFeatures: {
	//   },
	// },
	rules: {
		'strict': [0],
		'vars-on-top': 0,
		'global-require': 0,
		"indent": 0,
		"no-tabs":0,
		"prettier/prettier": 0,
		"spaced-comment":0,
		'new-cap':0,
	},
	parser: 'babel-eslint',
	parserOptions: {
		sourceType: 'module',
		allowImportExportEverywhere: true,
	},
};

然后上网搜索, 竟然发现一份中文资料:

"devDependencies": {
  "babel-eslint":"latest"
}
  • 然后重启, 问题就自然解决了.

官方的说法:

  • 先禁用eslint插件.
  • 重启vscode
  • 然后, 就清净了, 官方认为这种问题大多数是插件冲突造成的.

Stack Overflow说, 除了上面的依赖以外

  • eslint-plugin-react 这个依赖也需要安装.