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

CLI binaries from root/node_modules/.bin not found when running package.json scripts of subprojects with Nx #28483

Open
2 of 4 tasks
mklueh opened this issue Oct 17, 2024 · 0 comments

Comments

@mklueh
Copy link

mklueh commented Oct 17, 2024

Current Behavior

Hello, I've migrated my workspace from yarn to pnpm with the hope to get around this issue: wxt-dev/wxt#1058
with success so far.

However, now I'm facing a new problem which I haven't had before, and I'm not sure if it is Nx related, pnpm related or has something to do with the new Node installation (used Vola over NVM to install Node and pnpm).

I'm trying to run a build script from the package.json

  "scripts": {
    "print-env-info": "bash -c 'echo ${SHELL:-/bin/bash}; echo ${LANG:-en_US.UTF-8}; printenv'",
    "build": "nuxt generate" //pnpm nuxt generate also fails
}

and I'm getting this output error

$ pnpm nx run my-app:build

> [email protected] nx C:\Users\MyPc\Workspace\my-project
> nx "run" "my-app:build"


> nx run my-app:build

> [email protected] build C:\Users\MyPc\Workspace\my-project\apps\my-app
> nuxt generate
Der Befehl "nuxt" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
 ELIFECYCLE  Command failed with exit code 1.

For whatever reason, it is english mixed with german.

When I navigate to apps/my-app in the terminal and run nuxt build it works perfectly.

So it seems Nx has different environment variables than the Git bash I'm using in IntelliJ

To verify that, I've compared the output of running pnpm nx run my-app:print-env-info with running echo ${SHELL:-/bin/bash}; echo ${LANG:-en_US.UTF-8}; printenv manually in the terminal, and indeed, while the Nx command only points to ..../my-project/apps/my-app/node_modules/.bin the manual command from the terminal points to the root node_modules/.bin!

Another observation is that running the script in package.json with IntelliJ's RunConfiguration also fails with the same error.

This issue also appears to happen in GitHub Actions.

  1. Why do / can the environment variables differ?
  2. How can I tell Nx to use the root-level node_modules/.bin for whatever command it executes?

Expected Behavior

To behave identically to the local shell and find the binaries in the submodules

GitHub Repo

No response

Steps to Reproduce

As I have no idea what may influence the environment variables Nx is using (or even the shell) I'd like to get some information first to narrow down the scope

Nx Report

Node : 22.9.0
OS : win32-x64
Native Target : x86_64-windows
pnpm : 9.12.1

nx : 20.0.1
@nx/js : 20.0.1
@nx/jest : 20.0.1
@nx/eslint : 20.0.1
@nx/workspace : 20.0.1
@nx/devkit : 20.0.1
@nrwl/devkit : 19.6.0
@nx/esbuild : 20.0.1
@nx/eslint-plugin : 20.0.1
@nx/express : 20.0.1
@nx/node : 20.0.1
@nx/nuxt : 20.0.1
@nx/playwright : 20.0.1
@nx/vite : 20.0.1
@nx/vue : 20.0.1
@nx/web : 20.0.1
@nx/webpack : 20.0.1
typescript : 5.6.3

Registered Plugins:
@nx/vite/plugin
@nx/eslint/plugin
@nx/playwright/plugin

Community plugins:
@jnxplus/nx-gradle : 1.14.0
@theunderscorer/nx-semantic-release : 2.12.0

The following packages should match the installed version of nx

Failure Logs

No response

Package Manager Version

pnpm latest

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant