jstice4all
jstice4all

Reputation: 1948

Are there any side effects of having unix line endings when working on Windows machine?

I am working on Windows 7 and have a node.js project which is under git. I set up my TortoiseGit to autocrlf: false and safecrlf: false. Then changed all project files' line endings to LF. The project starts and operates normally and I see no reason to go back to CRLF.

Should I expect any side effects after doing this?

Upvotes: 4

Views: 2593

Answers (2)

Thomas Stringer
Thomas Stringer

Reputation: 5862

No, there is no problem at all using *nix end of line sequences on Windows (LF instead of CRLF). In fact, my personal recommendation would be to ensure your Windows editor (if you're developing node.js on Windows) to use LF.

Just as an example, I use Visual Studio Code for my editor developing node.js, and I have specified the following in my user settings to use LF instead of CRLF: "files.eol": "\n". Now I no longer need to worry about that.

CRLF line endings cause breaking issues in a node.js application that is run on Linux, and it isn't the most straightforward thing to troubleshoot if you don't know what to look for.

TL;DR Use LF while developing node.js applications on Windows if you really care about cross-platform (which you should care).

Note: just because git changes your line endings doesn't mean that is the solution. Even if you are ok with your version control changing your source code (which I don't recommend), if you do an npm publish it'll be using your source files locally and you could sneak CRLFs into the npm registry.

Upvotes: 6

MrTux
MrTux

Reputation: 34042

If all tools/editors/IDEs are LF compatible, then there is no problem.

Otherwiese you might get errors or mixed line endings on saving.

In order to make sure no conversion is happening for other users who clone your repository you can put a .gitattributes file into the root folder containing: * -crlf which disables all crlf conversions.

Upvotes: 3

Related Questions