CLI di pnpm
Short aliases#
Added in: v11.0.0
pn is available as a short alias for pnpm, and pnx as a short alias for pnpm dlx. You can use them anywhere you'd use pnpm or pnpx:
pn install
pn add express
pn build
pn test
pnx create-vue my-app
Differenze vs npm#
A differenza di npm, pnpm convalida tutte le opzioni. For example, pnpm install --target_arch x64 will
fail as --target_arch is not a valid option for pnpm install.
Some dependencies read an npm_config_ environment variable during their build.
pnpm does not set these variables from its options, so set the variable yourself:
npm_config_target_arch=x64 pnpm install.
Opzioni#
-C <path>, --dir <path>#
Run as if pnpm was started in <path> instead of the current working directory.
-w, --workspace-root#
Run as if pnpm was started in the root of the workspace instead of the current working directory.
Comandi#
Per ulteriori informazioni, vedere la documentazione per i singoli comandi CLI. Ecco un elenco di utili comandi equivalenti di npm per iniziare:
| comando npm | equivalente di pnpm |
|---|---|
npm install |
pnpm install |
npm i <pkg> |
pnpm add <pkg> |
npm run <cmd> |
pnpm <cmd> |
npx <pkg> |
pnx <pkg> |
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).
Since v11.28.0, this also works with --filter and --recursive: pnpm -r eslint runs the eslint script in the selected projects that have one, and when none of them has a script by that name, it runs the eslint command installed in their dependencies. pnpm run with --filter or -r still reports the missing script.
Environment variables#
Some environment variables that are not pnpm related might change the behaviour of pnpm:
These environment variables may influence what directories pnpm will use for storing global information:
XDG_CACHE_HOMEXDG_CONFIG_HOMEXDG_DATA_HOMEXDG_STATE_HOME
You can search the docs to find the settings that use these environment variables.