Should I add yarn-error.log to my .gitignore file?

danday74 picture danday74 · Mar 4, 2017 · Viewed 12.2k times · Source

Yarn has created yarn.lock and yarn-error.log.

I have been told not to add yarn.lock to my .gitignore file because it locks down the packages.

Should I ignore the latter?

Answer

Aurora0001 picture Aurora0001 · Mar 4, 2017

It makes sense to ignore the yarn-error.log—log files are only useful to debug your own copy of the code, so there's no need to upload it to the repository.

File should be uploaded to your repo when they are useful or needed to build your project. The yarn-error.log (as the name suggests) is an error log, so it's never read by Yarn. The whole point of it is that you read the log to find out what went wrong, and if you've not had any errors, it might not even exist at all.

gitignore.io, a service which generates .gitignore files, include yarn-error.log and yarn-debug.log in their .gitignore file for Node:

### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

It may be wise to follow their example if you're not sure what you need—most pre-made .gitignore files have thought this issue through and concluded that logs should generally be ignored.