刚开始学习Nuxt.js,安装的时候,频频出现错误,尤其时客户端(Client)运行失败多次,有一次客户端服务端都失败。
错误如下:
cdm显示的ERROR是:
TypeError:Cannot read property ‘eslint’ of undefined.
查找了资料,发现可能是babel版本太low,也可能是依赖的问题。
最后我把nuxt文件夹下的node_modules文件给删了,重新下载。
删除node_modules后,执行命令:
npm install
重新下载node_modules.
然后打开nuxt.config.js,将其中的“isClient",修改成”Client".
即,原本如下:
extend (config, ctx) {
if (ctx.isClient) {
config.module.rules.push({
enforce: 'pre',
test: /\.(js|vue)$/,
loader: 'eslint-loader',
exclude: /(node_modules)/
})
}
}
修改后:
extend (config, ctx) {
if (ctx.Client) {
config.module.rules.push({
enforce: 'pre',
test: /\.(js|vue)$/,
loader: 'eslint-loader',
exclude: /(node_modules)/
})
}
}
再重新运行即可。