Daniel G. Reina Daniel G. Reina - 7 months ago 54
JSON Question

npm package.json formatted in one line

I have this issue, and whenever I do

npm init
the file package.json is created, but it is formatted in one line. As you can imagine this is not practical to work with and I end up formatting it myself, which is not the best task in the world.


I have noticed that when I do
npm install
the file gets reformatted again to one line. This is very annoying and I'm sure it must be some configuration that I cannot find.

What should I change to have the file formatted from the beginning?



When npm creates and updates the files, it rewrites the line endings to unix-style LF whereas windows endings are CRLF. When using an editor that doesn't handle unix endings correctly, you will see the whole content in one line.

So: use an editor that can handle unix line endings correctly.