git commit -m '名字’时报一下错误:
[FAILED] npm run lint-staged:js [FAILED]
[FAILED] npm run lint-staged:js [FAILED]
[SUCCESS] Running tasks for staged files..
npm ERR! code EPERM
npm ERR! syscall open
npm ERR! path C:\Program Files\nodejs\node_cache\_cacache\tmp\6e53bf01
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, open 'C:\Program Files\nodejs\node_cache\_cacache\tmp\6e53bf01'
npm ERR! errno: -4048,
npm ERR! syscall: 'open',
npm ERR! path: 'C:\\Program Files\\nodejs\\node_cache\\_cacache\\tmp\\6e53bf01'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! Log files were not written due to an error writing to the directory: C:\Program Files\nodejs\node_cache\_logs
npm ERR! You can rerun the command with `--loglevel=verbose` to see the logs in your terminal
错误引起:
git提交时的检测代码规范机制
解决方案:
搜的方法是说:
- 检查lint-staged配置:在项目的package.json文件中,找到lint-staged字段
- 清除缓存: npm cache claen
- 我用的是以下方法,用来跳过检测机制,输入一下命令:
git commit --no-verify -m '提交名'
- 找到根目录.eslintignore文件,将src放入其中,git提交时跳过src目录中的检测机制
node_modules
dist
node_modules/*
src
注意:
使用–no-verify命令时,git将会忽略任何预定义的提交钩子脚本,包括lint-staged脚本,但是绕过提交是有风险的,使用前要自行检查提交的代码。