How do I run the system commands in javascript?

后端 未结 5 818
执念已碎
执念已碎 2020-12-06 06:08

I need to list all the files in the javascript such as \"ls\"??

5条回答
  •  星月不相逢
    2020-12-06 06:53

    An even easier way in node.js is:

    var fs = require('fs');
    var ls = fs.readdirSync('/usr');
    

    The variable ls now contains an array with the filenames at /usr.

提交回复
热议问题