以下介紹如何在 Node.js 腳本中執行 Shell 命令。
首先,從 child_process 中導入 child 模組:
import * as child from 'node:child_process';
// 或者
const child = require('node:child_process');
然後,你可以像這樣調用 child.exec():
child.exec(`mkdir test`);
以下介紹如何在 Node.js 腳本中執行 Shell 命令。
首先,從 child_process 中導入 child 模組:
import * as child from 'node:child_process';
// 或者
const child = require('node:child_process');
然後,你可以像這樣調用 child.exec():
child.exec(`mkdir test`);