#6031·berry

[Bug?]: Example to set a complex config does not work on Windows (Powershell / cmd)

Author: julianessCreated Dec 21, 2023Updated Sep 1, 2026
Labelsbug

Self-service

  • I'd be willing to implement a fix

Describe the bug

When trying to set the "npmRegistries" entry either via dot notation or with --json flag, configuration cannot be set neither in powershell, nor in cmd on Windows.

Even when the example from the doc is used, the command fails:

bash
yarn config set 'npmRegistries["//npm.example.com"].npmAuthToken' ffffffff-ffff-ffff-ffff-ffffffffffff

The problem occurs from the url. If it includes a "." (e.g. //npm.example.com) it fails to be parsed:

Usage Error: Unrecognized configuration settings found: npmRegistries['//npm'].example - run "yarn config -v" to see the list of settings supported in Yarn in C:\Users\MyUser\.yarnrc.yml (in C:\Users\MyUser\.yarnrc.yml)

The resulting .yarnrc.yml file has this entry set from now on:

npmRegistries:
  //npm:
    example:
      com:
        npmAuthToken: ffffffff-ffff-ffff-ffff-ffffffffffff

I only got the command running by replacing all the "." in the URL with something else. Then the command works, but of course the URL is wrong then.

When using the same command with json notation:

bash
yarn config set npmRegistries --json '{"//npm.example.com": {"npmAuthToken": "ffffffff-ffff-ffff-ffff-ffffffffffff"}}'

Results in:

Syntax Error: Unexpected token / in JSON at position 1
    at JSON.parse (<anonymous>)
    at Th.execute (C:\Users\MyUser\AppData\Local\node\corepack\yarn\4.0.2\yarn.js:407:1341)
    at async Th.validateAndExecute (C:\Users\MyUser\AppData\Local\node\corepack\yarn\4.0.2\yarn.js:94:787)
    at async as.run (C:\Users\MyUser\AppData\Local\node\corepack\yarn\4.0.2\yarn.js:98:3250)
    at async oPt (C:\Users\MyUser\AppData\Local\node\corepack\yarn\4.0.2\yarn.js:734:11269)
    at async sk (C:\Users\MyUser\AppData\Local\node\corepack\yarn\4.0.2\yarn.js:734:11625)

I did not get this command to run with --json option in any kind, results in error while parsing always. I've checked my notatation on a JSON validator though. There seems to be something odd when parsing the string parameter

To reproduce

Try executing the commands from the doc in a Windows powershell or cmd to reproduce.

Environment

bash
System:
    OS: Windows 10 10.0.19044
    CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11850H @ 2.50GHz
  Binaries:
    Node: 18.16.0 - ~\AppData\Local\Temp\\\xfs-bec47249\node.CMD
    Yarn: 4.0.2 - ~\AppData\Local\Temp\\\xfs-bec47249\yarn.CMD
    npm: 9.5.1 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.12.1 - C:\Program Files\nodejs\pnpm.CMD

Additional context

No response