Daniel G. Reina Daniel G. Reina - 1 year ago 135
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?


Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download