Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pnpm not working with nx - more explained inside #2944

Closed
iangregsondev opened this issue Apr 30, 2020 · 9 comments · Fixed by #3785
Closed

pnpm not working with nx - more explained inside #2944

iangregsondev opened this issue Apr 30, 2020 · 9 comments · Fixed by #3785

Comments

@iangregsondev
Copy link

Hi,

I am trying to use pnpm with nx. I have brand new project. I did a pnpm install

and it created the following .bin under node_modules (notice the missing nx)

image

if you look further down there is a .pnpm directory which contains it

image

executing NX from a nx repo that has been installed with NPM and NOT pnpm - gives the following - so it works

➜  deleteme2 git:(master) npm run nx

> deleteme2@0.0.0 nx /Users/ian/Development/Personal/typescript/deleteme2
> nx

Nx - Extensible Dev Tools for Monorepos.

But on the pnpm one

➜  instant-accounts git:(feature/initial-setup) ✗ npm run nx

> instant-accounts-ws@0.0.0 nx /Users/ian/Development/Personal/typescript/instant-accounts
> nx

sh: nx: command not found

Anybody managed to get a good workflow working with pnpm and nx ?

@FrozenPandaz
Copy link
Collaborator

Thank you for reporting and investigating the issue!

I see, so the issue is that @nrwl/cli is brought in by @nrwl/workspace which npm brings in to .bin but pnpm does not. To fix, @nrwl/cli should be a direct dependency. We wanted to avoid that to avoid so many dependencies when possible 🤔.

cc @vsavkin

bekos added a commit to bekos/nx that referenced this issue Sep 22, 2020
bekos added a commit to bekos/nx that referenced this issue Sep 22, 2020
Having `cli` as dependency of `workspace` was working because of the
flattened module structure that NPM/Yarn use. On stricter package
managers like PNPM and Yarn 2 this is not the case, and any `pnpm nx` or
`yarn nx` command was failing because `@nrwl/cli` couldn't be located.

ISSUES CLOSED: nrwl#2944
vsavkin pushed a commit that referenced this issue Sep 24, 2020
Having `cli` as dependency of `workspace` was working because of the
flattened module structure that NPM/Yarn use. On stricter package
managers like PNPM and Yarn 2 this is not the case, and any `pnpm nx` or
`yarn nx` command was failing because `@nrwl/cli` couldn't be located.

ISSUES CLOSED: #2944
vivekmore pushed a commit to vivekmore/nx that referenced this issue Sep 25, 2020
Having `cli` as dependency of `workspace` was working because of the
flattened module structure that NPM/Yarn use. On stricter package
managers like PNPM and Yarn 2 this is not the case, and any `pnpm nx` or
`yarn nx` command was failing because `@nrwl/cli` couldn't be located.

ISSUES CLOSED: nrwl#2944
Doginal pushed a commit to Doginal/nx that referenced this issue Nov 25, 2020
Having `cli` as dependency of `workspace` was working because of the
flattened module structure that NPM/Yarn use. On stricter package
managers like PNPM and Yarn 2 this is not the case, and any `pnpm nx` or
`yarn nx` command was failing because `@nrwl/cli` couldn't be located.

ISSUES CLOSED: nrwl#2944
@smasala
Copy link
Contributor

smasala commented Dec 12, 2021

For the record (if migrating to pnpm), you will need "nx": "nx" listed in your package.json under scripts

@npwork
Copy link

npwork commented Apr 17, 2022

pnpm nx
simply returns empty line and it's not in .bin

Screen Shot 2022-04-17 at 2 52 22 PM

Screen Shot 2022-04-17 at 2 52 59 PM

@smitroshin
Copy link

System info:

WSL Ubuntu 20.04.4 LTS

Packages:

nx: v14.1.4
pnpm: v7.0.1

I installed nx globally using pnpm add -g nx.
And it works using just nx command, but I receive warning:

image

After, I tried two ways: pnpm nx and pnpm exec nx.

Outside nx workspace:

image

Inside nx workspace:

image

So, inside the project from some reason these commands just returns new line.
I think I need to mention that nx is listed in project devDependecies.

After removing nx from project devDependecies, nx started to execute command twice and continue to return warning even if I use pnpm exec.

image

@Ontic-Entity
Copy link

Having similar issues on migration attempt.

@JoshuaEN
Copy link

The "bin" field is no longer specified in the @nrwl/cli package ( #9394 ).

"bin" is still specified in the nx package:

"nx": "./bin/nx.js"

Thus adding nx (note: not @nrwl/nx) as a direct dev dependency causes pnpm to correctly add nx to .bin, and thus should resolve the nx not found error.

@electroheadfx
Copy link

I have the same issue, "nx": "./bin/nx.js" are there, what is the advice to run pnpm with NX, locally (no work) or globally (with the warning) ?

@alexgorbatchev
Copy link

There are still issues with pnpm. Simply following NX tutorial and generating a new project then running pnpm i, nothing works in VSCode. The NX Console extension doesn't work and VSCode doesn't pick up on any types or modules. Removing node_modules and running npm i fixes all issues.

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants