我第一次尝试使用汇总,但我不明白为什么会出现此错误:
TypeError: eslint is not a function
我之前安装了 rollup (v1.1.0) 然后 eslint npm install rollup-plugin-eslint
(v5.0.0)这是我的 rollup.config.js
import babel from 'rollup-plugin-babel';
import eslint from 'rollup-plugin-eslint';
export default {
input: 'src/main.js',
output: {
format: 'iife',
file: 'build/js/main.min.js',
name: 'main'
},
plugins: [
eslint({
exclude: [
'src/styles/**',
]
}),
babel({
exclude: 'node_modules/**',
}),
],
}
当我使用 ./node_modules/.bin/rollup -c
我收到此错误 TypeError: eslint is not a function
. (注意:汇总仅使用 babel 即可正常工作)但是,如果我使用
npm run lint
,它会起作用在 package.json 中添加此代码"scripts": {
"lint": "eslint src/**"
}
汇总配置有什么问题?谢谢你的帮助
最佳答案
尝试改变:
- import eslint from 'rollup-plugin-eslint';
+ import { eslint } from 'rollup-plugin-eslint';
Release notes for v5.0.0
关于eslint - 汇总和 eslint : How can I fix this error "TypeError: eslint is not a function" using eslint with rollup?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54293089/