简体   繁体   English

如何从config.js文件中删除注释

[英]How do i remove comments from config.js file

How do i remove comments from config.js file it act as JSON file in my project. 我如何从config.js文件中删除注释,它在我的项目中充当JSON文件。 In my config file i have single line comments like this 在我的配置文件中,我有这样的单行注释

//comment goes here

and multi line comments like this 像这样的多行注释

/* comments goes here */

so i am using strip-json-comments to remove comments. 所以我正在使用strip-json-comments删除评论。 I installed it as globally using following command 我使用以下命令将其作为全局安装

npm install --global strip-json-comments

But the problem is whenever i am trying run this command in Node command i am getting error 但是问题是每当我尝试在Node命令中运行此命令时,我都会报错

strip-json-comments config.js  > config_comments_removed.js

Error is 错误是

'strip-json-comments' is not recognized as an internal or external command,operable program or batch file.

Please help me to get out of this problem Thanks in Advance 请帮助我摆脱这个问题在此先感谢

Try installing strip-json-comments-cli instead. 尝试改为安装strip-json-comments-cli strip-json-comments does not come with a CLI utility. strip-json-comments不附带CLI实用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM