npm package.json格式化为一行 [英] npm package.json formatted in one line

查看:354
本文介绍了npm package.json格式化为一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了这个问题,每当我执行npm init时,文件package.json就会创建,但格式为一行.正如您可以想象的那样,使用它是不切实际的,最终我自己对其进行了格式化,这并不是世界上最好的任务.

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.

编辑
我注意到,当我执行npm install时,文件再次重新格式化为一行.这很烦人,我敢肯定它一定是我找不到的某些配置.

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?

谢谢!

推荐答案

当npm创建并更新文件时,它将行尾重写为unix样式LF,而Windows尾部为CRLF.如果使用的编辑器无法正确处理Unix结尾,您将在一行中看到全部内容.

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.

因此:使用可以正确处理Unix行尾的编辑器.

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

这篇关于npm package.json格式化为一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆