Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

19.3 has a different behaviour on creating .npmrc #45881

Closed
mariovor opened this issue Dec 16, 2022 · 4 comments
Closed

19.3 has a different behaviour on creating .npmrc #45881

mariovor opened this issue Dec 16, 2022 · 4 comments
Labels
npm Issues and PRs related to the npm client dependency or the npm registry. wrong repo Issues that should be opened in another repository.

Comments

@mariovor
Copy link

mariovor commented Dec 16, 2022

Version

v19.3.0

Platform

Linux 8c48bb36138c 5.15.0-56-generic #62~20.04.1-Ubuntu SMP Tue Nov 22 21:24:20 UTC 2022 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

Executed in Docker:

  1. Clean container
  2. Execute a npm i in a folder not the home dir.
  3. Execute a npm config set ...

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior?

In node 19.2 -> Create .npmrc in home dir (in case of container /root/.npmrc)

What do you see instead?

In node 19.3 -> Create .npmrc in directory executed the npm i

Additional information

Not sure if this is expected, but I did not find anything in the Changelog. Caught this in our CI pipeline because it operated on ~/.npmrc.

@bnoordhuis
Copy link
Member

You should report that to npm. Node bundles npm but we don't maintain it.

@bnoordhuis bnoordhuis closed this as not planned Won't fix, can't repro, duplicate, stale Dec 16, 2022
@bnoordhuis bnoordhuis added npm Issues and PRs related to the npm client dependency or the npm registry. wrong repo Issues that should be opened in another repository. labels Dec 16, 2022
@mariovor
Copy link
Author

Sorry, my mistake.

@targos
Copy link
Member

targos commented Dec 16, 2022

@nodejs/npm FYI

lukekarrys added a commit to npm/cli that referenced this issue Jan 1, 2023
 ### Refactor Config Reading During `exec`

This removes the previous workarounds that were required due to tests
setting configs that were not available in the constructor of the
commands.

This also made the fix for nodejs/node#45881
easier since the config checks for workspaces can now all be made in the
command. The fix was to move the package.json detection to
`@npmcli/config` and use that boolean instead of setting
`location=project` which affected all commands such as `config set`
saving to the wrong location.

Some notable changes from this refactor include:
-  `execWorkspaces` no longer being passed the raw workspace filters and
   instead requiring `this.setWorkspaces()` to be called which was
   already being done in most commands
- `static workspaces = [true|false]` on all commands to indicate
  workspaces support. This is used in docs generation and whether to
  throw when `execWorkspaces` is called or not.

 ### Drop `fakeMockNpm` and refactor `mockNpm`

This refactor also drops `fakeMockNpm` in favor of `realMockNpm` (now
just `mockNpm`), and adds new features to `mockNpm`.

Some new features of `mockNpm`:

- sets all configs via argv so they are parsed before `npm.load()`. This
  is the most important change as it more closely resembles real usage.
- automatically resets `process.exitCode`
- automatically puts global `node_modules` in correct testdir based on platform
- more helpful error messages when used in unsupported ways
- ability to preload a command for execution
- sets `cwd` automatically to `prefix` and sets `globalPrefix` to the
  specified testdir

Note that this commit does not include the actual test changes, which
are included in the following commits for readability reasons.

 ### Linting

This also removes some of the one off linting rules that were set in the
past to reduce churn and fixes all remaining errors.
lukekarrys added a commit to npm/cli that referenced this issue Jan 1, 2023
 ### Refactor Config Reading During `exec`

This removes the previous workarounds that were required due to tests
setting configs that were not available in the constructor of the
commands.

This also made the fix for nodejs/node#45881
easier since the config checks for workspaces can now all be made in the
command. The fix was to move the package.json detection to
`@npmcli/config` and use that boolean instead of setting
`location=project` which affected all commands such as `config set`
saving to the wrong location.

Some notable changes from this refactor include:
-  `execWorkspaces` no longer being passed the raw workspace filters and
   instead requiring `this.setWorkspaces()` to be called which was
   already being done in most commands
- `static workspaces = [true|false]` on all commands to indicate
  workspaces support. This is used in docs generation and whether to
  throw when `execWorkspaces` is called or not.

 ### Drop `fakeMockNpm` and refactor `mockNpm`

This refactor also drops `fakeMockNpm` in favor of `realMockNpm` (now
just `mockNpm`), and adds new features to `mockNpm`.

Some new features of `mockNpm`:

- sets all configs via argv so they are parsed before `npm.load()`. This
  is the most important change as it more closely resembles real usage.
- automatically resets `process.exitCode`
- automatically puts global `node_modules` in correct testdir based on platform
- more helpful error messages when used in unsupported ways
- ability to preload a command for execution
- sets `cwd` automatically to `prefix` and sets `globalPrefix` to the
  specified testdir

Note that this commit does not include the actual test changes, which
are included in the following commits for readability reasons.

 ### Linting

This also removes some of the one off linting rules that were set in the
past to reduce churn and fixes all remaining errors.
@lukekarrys
Copy link
Member

This will be fixed in the upcoming npm@9.3.0 release: npm/cli#5974

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
npm Issues and PRs related to the npm client dependency or the npm registry. wrong repo Issues that should be opened in another repository.
Projects
None yet
Development

No branches or pull requests

4 participants