问题
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.
EDIT
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?
Thanks!
回答1:
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.
来源:https://stackoverflow.com/questions/38953302/npm-package-json-formatted-in-one-line