Skip to content

> NX Running global Nx CLI with PNPM may have issues. #16

@kopach

Description

@kopach

When running nx in pnpm managed repo, I get the following warning (which sometimes even results in not working command)

 >  NX   Running global Nx CLI with PNPM may have issues.

   Prefer to use "pnpm" (https://pnpm.io/cli/exec) to execute commands in this workspace.
    TIP  create a shortcut such as: alias pnx="pnpm nx --"

Using the alias from the TIP would break this autocompletion, so would be really great if the plugin could work with PNPM natively and run pnpm nx whenever nx is used.

Here is what I came up with as a solution for me:

In .zrhrc

function pnpm-nx() {
	local cmd=$BUFFER
	if [[ "$cmd" =~ ^nx ]]; then
		local new_cmd=$(echo $cmd | sed -E 's/^nx /pnpm nx /g')
		BUFFER="$new_cmd"
	fi
	zle accept-line
}

zle -N pnpm-nx
bindkey "^M" pnpm-nx

So, now whenever I type nx {command} it gets replaced by pnpm nx {command} automatically on Enter. This also doesn't break this autocompletion plugin

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions