nrwl / nx

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

nx local-registry fails with an exception: 'registry' is not a valid npm version #27135

Closed ErickRodrCodes closed 2 months ago

ErickRodrCodes commented 3 months ago

Current Behavior

after migrating from 19.3 to 19.5, I noted I can't run anymore local-registry.

In a windows machine, tried powershell and CMD both on the same outcome.

I pinpointed the error here:

image

which points to the repo here:

https://github.com/nrwl/nx/blob/09c0b3d31a4c29d90a3ac9197fb3c7082acf8b5d/packages/js/src/executors/verdaccio/verdaccio.impl.ts#L161

this could happen as npm config set 'registry' might not be compatible in certain instances. The keyword registry might cause an error on windows computers if it has single quotes around it.

Expected Behavior

The issue can easily be solved my running a conditional command that allows the execution of the right option.

search:

'${scopeName}registry'

replace with

${scopeName ? "'"+scopeName+"registry'" : 'registry'}

as a result it won't throw the respective error.

image

GitHub Repo

No response

Steps to Reproduce

  1. use nvs to setup node 20.14.0
  2. on a specific repo that has plugins, try to run nx local-registry
  3. use a windows machine. it is plausible mac computers might work properly.

Verdaccio will fail to execute with the error 'registry' is not a valid npm option

Nx Report

NX   Report complete - copy this into the issue template

Node   : 20.14.0
OS     : win32-x64
npm    : 10.8.2

nx (global)        : 19.3.1
nx                 : 19.5.3
@nx/js             : 19.5.3
@nx/jest           : 19.5.3
@nx/linter         : 19.5.3
@nx/eslint         : 19.5.3
@nx/workspace      : 19.5.3
@nx/angular        : 19.5.3
@nx/devkit         : 19.5.3
@nx/eslint-plugin  : 19.5.3
@nx/playwright     : 19.5.3
@nx/plugin         : 19.5.3
@nx/react          : 19.5.3
@nrwl/tao          : 19.5.3
@nx/vite           : 19.5.3
@nx/web            : 19.5.3
@nx/webpack        : 19.5.3
typescript         : 5.5.4
---------------------------------------
Registered Plugins:
@nx/playwright/plugin
@nx/eslint/plugin
@nx/vite/plugin
---------------------------------------
Local workspace plugins:
         @erickrodrcodes/nx-electron-vite

Failure Logs

0 verbose cli C:\Users\tboga\AppData\Local\nvs\default\node.exe C:\Users\tboga\AppData\Local\nvs\default\node_modules\npm\bin\npm-cli.js
1 info using npm@10.8.2
2 info using node@v20.14.0
3 silly config load:file:C:\Users\tboga\AppData\Local\nvs\node\20.14.0\x64\node_modules\npm\npmrc
4 silly config load:file:C:\git-projects\ErickRodrCodes\nx-plugins\.npmrc
5 silly config load:file:C:\Users\tboga\.npmrc
6 silly config load:file:C:\Users\tboga\AppData\Local\nvs\default\etc\npmrc
7 verbose title npm config set 'registry' http://localhost:4873/
8 verbose argv "config" "set" "'registry'" "http://localhost:4873/" "--location" "user"
9 verbose logfile logs-max:10 dir:C:\Users\tboga\AppData\Local\npm-cache\_logs\2024-07-25T21_26_53_392Z-
10 verbose logfile C:\Users\tboga\AppData\Local\npm-cache\_logs\2024-07-25T21_26_53_392Z-debug-0.log
11 info config set "'registry'" "http://localhost:4873/"
12 silly logfile start cleaning logs, removing 2 files
13 verbose stack Error: `'registry'` is not a valid npm option
13 verbose stack     at Config.set (C:\Users\tboga\AppData\Local\nvs\node\20.14.0\x64\node_modules\npm\lib\commands\config.js:186:15)
13 verbose stack     at Config.exec (C:\Users\tboga\AppData\Local\nvs\node\20.14.0\x64\node_modules\npm\lib\commands\config.js:151:20)
13 verbose stack     at C:\Users\tboga\AppData\Local\nvs\node\20.14.0\x64\node_modules\npm\lib\npm.js:251:63
13 verbose stack     at Object.start (C:\Users\tboga\AppData\Local\nvs\node\20.14.0\x64\node_modules\npm\node_modules\proc-log\lib\index.js:101:21)
13 verbose stack     at #exec (C:\Users\tboga\AppData\Local\nvs\node\20.14.0\x64\node_modules\npm\lib\npm.js:250:17)
13 verbose stack     at Npm.exec (C:\Users\tboga\AppData\Local\nvs\node\20.14.0\x64\node_modules\npm\lib\npm.js:207:25)
13 verbose stack     at module.exports (C:\Users\tboga\AppData\Local\nvs\node\20.14.0\x64\node_modules\npm\lib\cli\entry.js:65:29)
14 error `'registry'` is not a valid npm option
15 verbose cwd C:\git-projects\ErickRodrCodes\nx-plugins
16 verbose os Windows_NT 10.0.22631
17 verbose node v20.14.0
18 verbose npm  v10.8.2
19 verbose exit 1
20 verbose code 1
21 error A complete log of this run can be found in: C:\Users\tboga\AppData\Local\npm-cache\_logs\2024-07-25T21_26_53_392Z-debug-0.log

Package Manager Version

10.8.2

Operating System

Additional Information

No response

ErickRodrCodes commented 3 months ago

I identified the change happened in this feature: https://github.com/nrwl/nx/commit/28cd0c4eef99bc9da11ccd1772bf494c236672f5

github-actions[bot] commented 1 month ago

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.