pnpm add -g npm-run-all 指令用途 指令 `pnpm add -g npm-run-all` 的用途如下: ### 🔧 指令解析 - `pnpm`: 是一個高效能的 JavaScript 套件管理工具,類似於 `npm` 或 `yarn`,但更快且節省磁碟空間。 - `add`: 表示安裝套件。 - `-g`: 表示全域安裝(global),讓這個套件可以在任何地方的命令列中使用。 - `npm-run-all`: 是一個工具套件,用來**同時或依序執行多個 npm script**,比原生的 `npm run` 更強大。 --- ### 📦 `npm-run-all` 的用途 `npm-run-all` 主要用來簡化與強化 `package.json` 中的 script 執行方式,常見功能包括: - **順序執行多個 script**: ```bash npm-run-all script1 script2 script3 ``` 會依序執行 `script1` → `script2` → `script3`。 - **並行執行多個 script**: ```bash npm-run-all --parallel script1 script2 ``` 會同時執行 `script1` 和 `script2`。 - **使用萬用字元批次執行 script**: ```bash npm-run-all lint:* test:* ``` 可以一次執行所有以 `lint:` 和 `test:` 開頭的 script。 --- ### ✅ 使用情境範例 假設你的 `package.json` 有以下 script: ```json { "scripts": { "clean": "rimraf dist", "build:js": "webpack", "build:css": "sass src/styles:dist/styles", "build": "npm-run-all clean build:*" } } ``` 執行 `npm run build` 時,會先執行 `clean`,再依序執行 `build:js` 和 `build:css`,這就是 `npm-run-all` 的威力。 --- 需要我幫你寫一個實際的 `package.json` 範例或是整合到某個專案中嗎?