如何解决npx eslint <文件名> 命令在 WSL 中不起作用
当我在安装 npx eslint <filename>
的目录中使用 eslint
时,它可以工作,但它也会记录以下错误消息:
ninadk@LAPTOP-63DSS7B4:~/launch_school$ npx eslint locale.js
/home/ninadk/launch_school/locale.js
2:1 error Expected indentation of 2 spaces but found 1 indent
✖ 1 problem (1 error,0 warnings)
1 error and 0 warnings potentially fixable with the `--fix` option.
npm ERR! code 1
npm ERR! path /home/ninadk/launch_school
npm ERR! command failed
npm ERR! command sh -c eslint locale.js
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ninadk/.npm/_logs/2021-02-11T10_00_00_361Z-debug.log
如果我尝试在子目录中运行 npx eslint <filename>
,它会记录:
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/ninadk/launch_school/js101-programming-foundations-with-js/lesson2/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory,open '/home/ninadk/launch_school/js101-programming-foundations-with-js/lesson2/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ninadk/.npm/_logs/2021-02-11T10_00_33_856Z-debug.log
如果我改用路径,它在父目录和它的子目录中都可以正常工作。
即../../node_modules/.bin/eslint calculator.js
。
我在父目录中创建了一个 .eslintrc.yml
文件并安装了 eslint:
npm install eslint eslint-cli babel-eslint --save-dev
。
有没有一种方法可以在不全局下载 eslint 的情况下使用 npx eslint
而不是所有子目录中的整个路径?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。