node.js - 使用babel后console.log中输出“\033”时程序报错 如何解决
高洛峰
高洛峰 2017-04-17 15:50:22
0
1
731
console.log('\033[33m[' + myDate.toLocaleTimeString() + ']\033[0m '+'新用户[ID '+mine.uid+']登记成功');

console.log时想要文字带上色彩,所以033[33m[这样的代码,但增加babel组件使用自动转换,启动时提示在这里报错
只能暂时再加一条斜杠先让程序跑起来,但命令行中色彩效果全没了。

console.log('\\033[33m[' + myDate.toLocaleTimeString() + ']\\033[0m '+'新用户[ID '+mine.uid+']登记成功');

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(1)
迷茫

No one invited me, I came by myself. . . .

This problem should be regarded as a relatively niche problem. I happened to encounter it before when doing color output. At that time, it was not a problem caused by babel conversion, but the strict mode enabled by nodejs node --use-strict code>problem. node --use-strict出的问题。

033换成x1b

Just replace 033 with x1b🎜
console.log('\x1b[33m 23333');
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template