pnpm CLI
與 npm 的差異
與 npm 不同,pnpm 會驗證所有的選項。 例如,執行 pnpm install --target_arch x64
將會失敗,因為 --target_arch
不是 pnpm install
有效的選項。
不過,部分依賴套件可能會使用 npm_config_
環境變數,該變數 是來自 CLI 的選項。 在這種情況下,您有下列選項:
- 設置明確的環境變數:
npm_config_target_arch=x64 pnpm install
- 使用
--config.
來強制執行未知的選項:pnpm install --config.target_arch=x64
參數
-C <path>, --dir <path>
取代目前的工作目錄改由 <path>
為開頭的路徑執行 pnpm。
-w, --workspace-root
新增於 v5.6.0
取代目前的工作目錄,使 pnpm 改由 workspace 的根目錄啟動。
Commands
如需相關資訊,請參閱個別 CLI 指令的說明文件。 以下為一些簡易的 npm 等價指令,以幫助您入門:
npm 指令 | pnpm 指令 |
---|---|
npm install | pnpm install |
npm i <pkg> | [pnpm add <pkg> ] |
npm run <cmd> | [pnpm <cmd> ] |
When an unknown command is used, pnpm will search for a script with the given name, so pnpm run lint
is the same as pnpm lint
. If there is no script with the specified name, then pnpm will execute the command as a shell script, so you can do things like pnpm eslint
(see pnpm exec).