添加Ctrl-M(^ M)字符时出现问题

问题描述 投票:1回答:1

我们的应用程序建立在MEAN堆栈上,最近我们遇到了一个从来没有问题的问题。

进行了代码更改,并自动添加Ctrl-M字符。这只发生在一个js和html文件中。所有其他人都没有任何问题。

请在下面找到一个git diff。

        new CronJob("01 * * * * *", function () {
-               console.log("Notify cron");
+               console.log("Notify Cron");^M
                notificationController.notifyCron();
        }, null, true, 'America/Los_Angeles');
        new CronJob("01 * * * * *", function () {
-               console.log("Notify cron");
+               console.log("Notify Cron Message");^M
                notificationController.notifyCronMessage();
     }, null, true, 'America/Los_Angeles');

截图,也是... screenshot

请注意,修改后的行会插入一个附加字符。我已经研究了几乎所有关于这个问题的可用内容,并且有一些解决方案允许我们在linux服务器上进行更改。

但是,我希望这根本不会发生。我在macOS上使用Visual Studio Code ...

任何帮助将不胜感激。

javascript node.js mean-stack
1个回答
0
投票

我想你已经使用windows更改了文件。

^M at the end of every line in vim

如果要将文件转换回linux行结尾,请使用dos2unix。

© www.soinside.com 2019 - 2024. All rights reserved.