`aws codeartifact login --tool npm` fails with "This command does not support workspaces."
- Dominant language
- Python
- Stars
- 17.3k
- Forks
- 4.6k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 13
Description
### Describe the bug
I cannot run `aws codeartifact login --tool npm` when inside of a npm workspace. The command fails with "This command does not support workspaces". See the "Reproduction Steps" below for more details.
### Expected Behavior
I expect to be able to run this command anywhere and have it behave the same (that is, update my `~/.npmrc` file).
### Current Behavior
See the "Reproduction Steps" below for an example of how to repro with the errors inline.
### Reproduction Steps
To reproduce, create a simple npm workspace and cd into it. I've created a dead simple repo for this:
$ git clone https://github.com/jfly/simple-npm-workspace.git
$ cd simple-npm-workspace/workspace-a
And here's a (redacted) `aws codeartifact login` command that fails:
$ aws codeartifact login --domain ... --repository ... --domain-owner ... --region ... --tool npm --namespace=...
Command '['npm', 'config', 'set', '...:registry', '...']' returned non-zero exit status 1. Stderr from command:
npm ERR! code ENOWORKSPACES
npm ERR! This command does not support workspaces.
npm ERR! A complete log of this run can be found in: /home/jeremy/.npm/_logs/2024-02-29T19_52_57_750Z-debug-0.log
Or, here's a simpler command that is not redacted:
$ npm config set @foo:registry https://example.com
npm ERR! code ENOWORKSPACES
npm ERR! This command does not support workspaces.
npm ERR! A complete log of this run can be found in: /home/jeremy/.npm/_logs/2024-02-29T19_54_42_376Z-debug-0.log
### Possible Solution
This is arguably a bug with npm itself, and it's already filed upstream in https://github.com/npm/cli/issues/6099. I can't tell if they're interested in fixing this, though. There is a workaround [described here](https://github.com/npm/cli/issues/6099#issuecomment-1961995288), which would be easy to port to [the relevant calls to `npm config set` in aws-cli](https://github.com/aws/aws-cli/blob/2.15.24/awscli/customizations/codeartifact/login.py#L486-L507).
I'd be happy to send in a PR implementing this workaround if you're open to it.
### Additional Information/Context
_No response_
### CLI version used
2.15.24
### Environment details (OS name and version, etc.)
Linux (NixOS unstable)
Contributor guide
Assessment
This issue has not been assessed yet.