eslint错误怎么解决?

eslint错误怎么解决?

迁移项目的时候,刚开始安装依赖就出现错误,如下图:

http://img1.sycdn.imooc.com//climg/601ab1ee09fb3ade06710239.jpg


新建tabbar的index.vue页面后,运行npm run lint -- --fix又出现错误,如下图:

http://img1.sycdn.imooc.com//climg/601ab2b8095ddb5608550476.jpg


打开C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2021-02-03T14_26_18_966Z-debug.log中的错误日志,代码如下,老师帮忙看看怎么解决:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'lint',
1 verbose cli '--',
1 verbose cli '--fix'
1 verbose cli ]
2 info using npm@6.14.6
3 info using node@v12.18.4
4 verbose run-script [ 'prelint', 'lint', 'postlint' ]
5 info lifecycle mall@1.0.0~prelint: mall@1.0.0
6 info lifecycle mall@1.0.0~lint: mall@1.0.0
7 verbose lifecycle mall@1.0.0~lint: unsafe-perm in lifecycle true
8 verbose lifecycle mall@1.0.0~lint: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;L:\练习\慕课网职业路径\mall\node_modules\.bin;L:\练习\慕课网职业路径\mall\node_modules\.bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Common Files\microsoft shared\TigerKin;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Users\Administrator\AppData\Roaming\npm
9 verbose lifecycle mall@1.0.0~lint: CWD: L:\练习\慕课网职业路径\mall
10 silly lifecycle mall@1.0.0~lint: Args: [ '/d /s /c', 'eslint --ext .js,.vue src "--fix"' ]
11 silly lifecycle mall@1.0.0~lint: Returned: code: 1 signal: null
12 info lifecycle mall@1.0.0~lint: Failed to exec lint script
13 verbose stack Error: mall@1.0.0 lint: `eslint --ext .js,.vue src "--fix"`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:315:20)
13 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:315:20)
13 verbose stack at maybeClose (internal/child_process.js:1021:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid mall@1.0.0
15 verbose cwd L:\练习\慕课网职业路径\mall
16 verbose Windows_NT 6.1.7601
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "lint" "--" "--fix"
18 verbose node v12.18.4
19 verbose npm v6.14.6
20 error code ELIFECYCLE
21 error errno 1
22 error mall@1.0.0 lint: `eslint --ext .js,.vue src "--fix"`
22 error Exit status 1
23 error Failed at the mall@1.0.0 lint script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]


正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

2回答
好帮手慕言 2021-02-04 14:05:56

同学你好,黄色的是没有关系的,不会影响项目的运行。同学可以先运行一下项目,如果项目不能运行的话,可以把报错和自己写的代码贴出来,老师帮助测试。

另外:如果项目可以运行,控制台有类似于下图的提示

http://img1.sycdn.imooc.com//climg/601b8dd009077bb907590338.jpg

也是没有关系的,这是eslint发出的警告,如果同学不想看见这些警告,可以去掉,操作如下:

http://img1.sycdn.imooc.com//climg/601b8e8c09444ea411380422.jpg

http://img1.sycdn.imooc.com//climg/601b8ea70991a1ae12500264.jpg

祝学习愉快~

好帮手慕言 2021-02-04 10:24:34

同学你好,解答如下:

1、第一张截图上是没有报错的,如果有报错的话,会有ERR单词。

2、从提供的信息上来看,是tabbar/index.vue文件出了问题,可以看看此文件中的结构是不是如下方(外层有且只有一个标签嵌套):

http://img1.sycdn.imooc.com//climg/601b591d099a963503800238.jpg

如果修改之后,还是不可以的话,建议:把tabbar/index.vue文件中的代码粘贴上来,老师帮助解答。

祝学习愉快~

  • 提问者 人生的起源 #1

    tabbar/index.vue文件没有问题,是刚新建的,<template>标签下也只有一个标签

    第一张图是有错误提示的,老师仔细看黄色的字,里面有error

    2021-02-04 10:50:04
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
热门框架Vue开发WebApp 18版
  • 参与学习           人
  • 提交作业       209    份
  • 解答问题       3299    个

本路径是通过ES6基础知识、运用Zepto、Swiper、fullPag等移动端常用工具包、以及当下流行框架Vue,结合多个实战案例,还原真实开发场景,最终实现手机端购物商城网页开发。

了解课程
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师