You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] npm WARN ignoring workspace config at /my-project/my-workspace/.npmrcΒ #4605
npm ignores workspace .npmrc if running command from workspace directory.
This was encountered via CI loose allowance of node major version 16. The same CI job succeeded on 16.14.0 and failed on 16.14.2. Thus, it seems this was introduced in the npm minor version bumps included in node 16.14.1.
$ cd my-workspace
$ npm --version
npm WARN ignoring workspace config at my-project/my-workspace/.npmrc
...
This of course is a more pressing issue for commands like npm publish.
Expected Behavior
It should carry the same behavior it has had, which is to respect workspace .npmrc files.
Steps To Reproduce
In node 16.14.2 with npm 8.5+
With workspaces.
Change directory into your workspace and run npm --version.
See warning.
If you run this for npm publish, it will fail due to lack of necessary auth information set in .npmrc.
Environment
My local:
npm: 8.5.5
Node.js: 16.17.5
OS Name: MacOS and Debian
System Model Name: MBP
npm config:
; node bin location = /Users/me/.nvm/versions/node/v14.17.5/bin/node; cwd = /Users/me/Repos/my-repo; HOME = /Users/me
Reacted by Andrey Golovin, TobinXu, Δα» Sinh and Saren
changed the title [-][BUG] npm WARN ignoring workspace config at /my-workspace/.npmrc[/-][+][BUG] npm WARN ignoring workspace config at /my-project/my-workspace/.npmrc[/+]on Mar 23, 2022
Hi @JustinTRoss, thanks for taking the time to reporting this.
npm ignores workspace .npmrc if running command from workspace directory.
That's intentional behavior, starting with npm@8.5.0 we shipped a new feature to make sure workspaces are properly tracked when running npm commands from within workspaces folders, ref: https://github.com/npm/cli/releases/tag/v8.5.0
I see three different possible solutions:
In case all workspaces share the same auth values, using a single .npmrc file in the root folder should fix it
If you want to continue using the values from the workspace folder .npmrc and force the npm cli to not track that as a workspace, you can opt-out of the default behavior by running your commands with --no-workspaces, e.g: npm publish --no-workspaces
Hope that helps!
Reacted by vp-cmenna, Mario Arnautou, Roman Chernukhin, Daniel Zegarra, Pablo Espinosa, Milos Dodovic, WhereJuly, Tiago Amaro, Zim, Alex Nault and 2 more
Thanks for the quick response. I understand that the behavior changed in 8.5, and I can understand the inspiration for the change. I'm confused however, why we would ship features that break the existing api in minor versions of npm and then include those changes in patch versions of NodeJS.
Are there any resources you can point me to to adjust my expectations for when to expect breaking changes with regard to npm and how to insulate myself from them? Should I generally expect exposure to breaking changes anytime I don't lock Node and npm down to the patch?
Reacted by Mike MacCana, Matthias OΓwald, BalΓ‘zs OrbΓ‘n, Sten Petrov, Sergey Romanchuk, Brycen G, Ilber Ibrahimi, Mikhail, KazimirPodolski, bobbleniblet and 2 more
Every bug fix is a potential breaking change, and vice versa. Since this one isnβt considered breaking, landing it in a mine is fine, and node would follow suit.
Itβs entirely possible it is breaking, but that can get subjective when youβre talking about undocumented behavior compared with the intentions of authors vs the expectations of users.
Reacted by Ruy Adorno and Justin Ross
Reacted by Sergey Romanchuk, Arthur Kepler, Xavier Le Cunff and Gelu Timoficiuc
hi @JustinTRoss I believe @ljharb very eloquently explained the kind of trade offs we have to balance when working on fixes, new features and when to label them as breaking changes.
To answer to your specific use case, running npm commands from workspaces folders was not a supported use case up to npm@8.5.0 as you can see the in our Working with Workspaces page the examples there will always refer to running commands from the root folder and using the -w config option to target a specific workspace, e.g: npm publish -w <workspace-name>. With that in mind we decided to label that a feature instead of a breaking change.
Thank you both for taking the time to explain π .
I think I understand now. It sounds like if this directory hadn't been listed as a workspace, it wouldn't have been affected. It's a sort of conflict of perspective on what behavior belongs to what subset of the API, here with vs without workspaces.
As I understand it, npm uses local .npmrc from the current folder with package.json by design. When using workspaces however, there was no added functionality around .npmrc handling, so that default behavior was retained. When we introduced the workspaces-specific feature, we stopped deferring to the default behavior of local .npmrc and instead used the root .npmrc.
Where I was thinking of workspaces as a modification on top of default behavior, it sounds like I should be thinking of it as a complete alternative where any defaulting to non-workspace behavior is just happenstance.
Activity
[-][BUG] npm WARN ignoring workspace config at /my-workspace/.npmrc[/-][+][BUG] npm WARN ignoring workspace config at /my-project/my-workspace/.npmrc[/+]ruyadorno commentedon Mar 23, 2022
Hi @JustinTRoss, thanks for taking the time to reporting this.
That's intentional behavior, starting with
npm@8.5.0we shipped a new feature to make sure workspaces are properly tracked when runningnpmcommands from within workspaces folders, ref: https://github.com/npm/cli/releases/tag/v8.5.0I see three different possible solutions:
.npmrcfile in the root folder should fix itpublishConfigpackage.jsonvalue, ref: https://docs.npmjs.com/cli/v8/configuring-npm/package-json#publishconfig.npmrcand force the npm cli to not track that as a workspace, you can opt-out of the default behavior by running your commands with--no-workspaces, e.g:npm publish --no-workspacesHope that helps!
JustinTRoss commentedon Mar 24, 2022
Thanks for the quick response. I understand that the behavior changed in 8.5, and I can understand the inspiration for the change. I'm confused however, why we would ship features that break the existing api in minor versions of npm and then include those changes in patch versions of NodeJS.
Are there any resources you can point me to to adjust my expectations for when to expect breaking changes with regard to npm and how to insulate myself from them? Should I generally expect exposure to breaking changes anytime I don't lock Node and npm down to the patch?
ljharb commentedon Mar 24, 2022
Every bug fix is a potential breaking change, and vice versa. Since this one isnβt considered breaking, landing it in a mine is fine, and node would follow suit.
Itβs entirely possible it is breaking, but that can get subjective when youβre talking about undocumented behavior compared with the intentions of authors vs the expectations of users.
ruyadorno commentedon Mar 24, 2022
hi @JustinTRoss I believe @ljharb very eloquently explained the kind of trade offs we have to balance when working on fixes, new features and when to label them as breaking changes.
To answer to your specific use case, running npm commands from workspaces folders was not a supported use case up to
npm@8.5.0as you can see the in our Working with Workspaces page the examples there will always refer to running commands from the root folder and using the-wconfig option to target a specific workspace, e.g:npm publish -w <workspace-name>. With that in mind we decided to label that a feature instead of a breaking change.JustinTRoss commentedon Mar 24, 2022
Thank you both for taking the time to explain π .
I think I understand now. It sounds like if this directory hadn't been listed as a workspace, it wouldn't have been affected. It's a sort of conflict of perspective on what behavior belongs to what subset of the API, here with vs without workspaces.
As I understand it, npm uses local
.npmrcfrom the current folder withpackage.jsonby design. When using workspaces however, there was no added functionality around.npmrchandling, so that default behavior was retained. When we introduced the workspaces-specific feature, we stopped deferring to the default behavior of local.npmrcand instead used the root.npmrc.Where I was thinking of workspaces as a modification on top of default behavior, it sounds like I should be thinking of it as a complete alternative where any defaulting to non-workspace behavior is just happenstance.
chore: use `--no-workspaces`
Remove .npmrc from workspaces
Remove .npmrc from workspaces
Fix workspace npm/cli#4605
setup for using npm workspace
chore: use `--no-workspaces`
chore: use `--no-workspaces`