nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.16k stars 2.31k forks source link

NX format can't find path to prettier config #26794

Closed shanahobo86 closed 2 weeks ago

shanahobo86 commented 2 months ago

Current Behavior

Since upgrading to nx 18.2.0, I get a strange error when trying to run nx format:write which suggests nx can't find the prettier path. I can run prettier commands directly in the cli it's just NX format that doesn't appear to work.

Expected Behavior

nx format reads my prettier config and formats as expected

GitHub Repo

No response

Steps to Reproduce

1.

Nx Report

NX   Report complete - copy this into the issue template

Node   : 21.7.3
OS     : win32-x64
npm    : 6.14.17

nx                 : 18.2.0
lerna              : 3.22.1
@nx/js             : 18.2.0
@nx/jest           : 18.2.0
@nx/linter         : 18.2.0
@nx/eslint         : 18.2.0
@nx/workspace      : 18.2.0
@nx/angular        : 18.2.0
@nx/devkit         : 18.2.0
@nx/eslint-plugin  : 18.2.0
@nrwl/tao          : 18.2.0
@nx/web            : 18.2.0
@nx/webpack        : 18.2.0
typescript         : 5.4.5
---------------------------------------
Community plugins:
@ngrx/effects        : 17.0.1
@ngrx/router-store   : 17.0.1
@ngrx/schematics     : 17.0.1
@ngrx/store          : 17.0.1
@ngrx/store-devtools : 17.0.1
ng-mocks             : 14.13.0
ngx-bootstrap        : 11.0.2
ngx-toastr           : 16.2.0

Failure Logs

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Object
    at Object.join (node:path:433:7)
    at getPrettierPath (C:\Users\________\node_modules\nx\src\command-line\format\format.js:154:33)
    at Module._compile (node:internal/modules/cjs/loader:1368:14)
    at Module.load (node:internal/modules/cjs/loader:1205:32)
    at Module._load (node:internal/modules/cjs/loader:1021:12)
    at Module._load (node:internal/modules/cjs/loader:1021:12)
    at Module.require (node:internal/modules/cjs/loader:1230:19)
    at Mod.require (C:\Users\________\node_modules\nx\bin\init-local.js:157:36)
    at require (node:internal/modules/helpers:179:18) {
  code: 'ERR_INVALID_ARG_TYPE'
}

Package Manager Version

No response

Operating System

Additional Information

No response

AgentEnder commented 1 month ago

This is potentially related: https://github.com/nrwl/nx/pull/18672

What version of prettier do you have installed?

shanahobo86 commented 1 month ago

Hi @AgentEnder, I was originally on 2.6.2 when I saw this issue. Subsequently bumped to the latest (3.3.2) but still seeing the same.

AgentEnder commented 1 month ago

Interesting, @shanahobo86 could you attach a repository showing this behavior? I've not been able to reproduce.

github-actions[bot] commented 1 month ago

This issue has been automatically marked as stale because no reproduction was provided within 7 days. Please help us help you. Providing a repository exhibiting the issue helps us diagnose and fix the issue. Any time that we spend reproducing this issue is time taken away from addressing this issue and other issues. This issue will be closed in 21 days if a reproduction is not provided. If a reproduction has been provided, please reply to keep it active. Thanks for being a part of the Nx community! 🙏