它可能不是 eslint 缓存。
我正在一个项目中工作,该项目使用本地 package.json 中引用的自定义 eslint 插件(未在 npm 上发布)。
"special-eslint-plugin": "file:special-eslint-plugin-directory"
但是后来我切换到一个没有这个包的旧分支。它没有安装在 node_modules 中,它不在 package.json 或 shrinkwrap 中,它不是本地目录。当我运行“npm run lint”(运行 grunt lint)时,我得到了这个终端输出:
10:31 AM app $ npm run lint
npm info it worked if it ends with ok
npm info using npm@5.5.1
npm info using node@v8.9.2
npm info lifecycle phApp@1.77.0~prelint: phApp@1.77.0
npm info lifecycle phApp@1.77.0~lint: phApp@1.77.0
> phApp@1.77.0 lint /Users/****/Desktop/app/app/
> grunt lint
Running "lint" task
Running "eslint:target" (eslint) task
Warning: Failed to load plugin special-eslint-plugin: Cannot find module 'special-eslint-plugin' Use --force to continue.
Aborted due to warnings.
Execution Time (2018-10-09 10:31:52 UTC-7)
/ ... /
npm info lifecycle phApp@1.77.0~lint: Failed to exec lint script
npm ERR! code ELIFECYCLE
npm ERR! errno 6
npm ERR! phApp@1.77.0 lint: `grunt lint`
npm ERR! Exit status 6
npm ERR!
npm ERR! Failed at the phApp@1.77.0 lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/***/.npm/_logs/2018-10-09T17_31_53_336Z-debug.log
所以我认为 eslint 缓存以某种方式跨分支持续存在,它认为它需要那个包。
我尝试过但不限于以下内容:
git clean -xfd && npm cache clear --force && nvm use && npm install
- 重新安装节点和 npm
- 重新安装 nvm
- 删除我所有的全局包
- 禁用我所有的编辑器包(我在 IDE 中有 linter)
- 删除本地分支
- 重新启动我的电脑
我在用:
- 咕噜声
- 咕噜声
- “节点”:“8.9.2”
- “npm”:“5.5.1”
- 非虚拟机 0.30.2
有一个运行 lint 的 git 钩子,所以它阻止我在这个分支上完成工作
最有趣的部分是,在他们切换到我所在的分支并运行上面的 git clean 命令后,我的同事机器上并没有发生这种情况。所以这与我的计算机有关,而不是与分支有关。
谢谢