CLI documentation update from CI
npm CLI robot committed
May 21, 2025 at 22:27 UTC
2aa2821da3b7df33969abe4b6d58a77d9bcc0176
7 files changed
+38
-7
cli-cache.json
+1
-1
@@ -2,5 +2,5 @@
2
"v8": "aa8fff11cdab94fff1a2160ee5241f5f4632e96b",
3
"v9": "64763a341e7aa5b456e696f956759bf9b3440dc1",
4
"v10": "e510f14bf6a20d67e7b37c3f25ff271d9f7a0da5",
5
- "v11": "8f6eb6b29904b5a807c5c4c01c1246afc70a77f1"
5
+ "v11": "5d7a7a8695135812d55f42ab03513c705d7fd785"
6
}
\ No newline at end of file
content/cli/v11/commands/npm-ls.mdx
+1
-1
@@ -52,7 +52,7 @@ Note: to get a "bottoms up" view of why a given package is included in the tree
52
Positional arguments are `name@version-range` identifiers, which will limit the results to only the paths to the packages named. Note that nested packages will _also_ show the paths to the specified packages. For example, running `npm ls promzard` in npm's source tree will show:
53
54
```bash
55
-npm@11.4.0 /path/to/npm
55
+npm@11.4.1 /path/to/npm
56
└─┬ init-package-json@0.0.4
57
└── promzard@0.1.5
58
```
content/cli/v11/commands/npm.mdx
+1
-1
@@ -31,7 +31,7 @@ Note: This command is unaware of workspaces.
31
32
### Version
33
34
-11.4.0
34
+11.4.1
35
36
### Description
37
content/cli/v11/using-npm/changelog.mdx
+19
@@ -15,6 +15,25 @@ redirect_from:
15
- /using-npm/changelog
16
---
17
18
+## [11.4.1](https://github.com/npm/cli/compare/v11.4.0...v11.4.1) (2025-05-21)
19
+
20
+### Documentation
21
+
22
+- [`3ed764a`](https://github.com/npm/cli/commit/3ed764aa08f2087fa1d1bd7391a646ba47565294) [#8308](https://github.com/npm/cli/pull/8308) Clarify script working directory behavior (fixes #8305) (#8308) (@tarekwfa0110, @owlstronaut)
23
+
24
+### Chores
25
+
26
+- [`2f30251`](https://github.com/npm/cli/commit/2f302516401928239593dd2eebc171729df60537) [#8314](https://github.com/npm/cli/pull/8314) remove references to skimdb.npmjs.com (#8314) (@shmam)
27
+- [`9cb9d50`](https://github.com/npm/cli/commit/9cb9d5030b1fdb83e3ffa45b7c8d2de80a657768) [#8298](https://github.com/npm/cli/pull/8298) add contributor to changelog entry (#8298) (@wraithgar)
28
+
29
+### Dependencies
30
+
31
+- [workspace](https://github.com/npm/cli/releases/tag/arborist-v9.1.1): `@npmcli/arborist@9.1.1`
32
+- [workspace](https://github.com/npm/cli/releases/tag/libnpmdiff-v8.0.4): `libnpmdiff@8.0.4`
33
+- [workspace](https://github.com/npm/cli/releases/tag/libnpmexec-v10.1.3): `libnpmexec@10.1.3`
34
+- [workspace](https://github.com/npm/cli/releases/tag/libnpmfund-v7.0.4): `libnpmfund@7.0.4`
35
+- [workspace](https://github.com/npm/cli/releases/tag/libnpmpack-v9.0.4): `libnpmpack@9.0.4`
36
+
37
## [11.4.0](https://github.com/npm/cli/compare/v11.3.0...v11.4.0) (2025-05-15)
38
39
### Features
content/cli/v11/using-npm/registry.mdx
-2
@@ -27,8 +27,6 @@ You can configure npm to use any compatible registry you like, and even run your
27
28
npm's package registry implementation supports several write APIs as well, to allow for publishing packages and managing user account information.
29
30
-The npm public registry is powered by a CouchDB database, of which there is a public mirror at [https://skimdb.npmjs.com/registry](https://skimdb.npmjs.com/registry).
31
-
30
The registry URL used is determined by the scope of the package (see [`scope`](/cli/v11/using-npm/scope). If no scope is specified, the default registry is used, which is supplied by the [`registry` config](/cli/v11/using-npm/config#registry) parameter. See [`npm config`](/cli/v11/commands/npm-config), [`npmrc`](/cli/v11/configuring-npm/npmrc), and [`config`](/cli/v11/using-npm/config) for more on managing npm's configuration. Authentication configuration such as auth tokens and certificates are configured specifically scoped to an individual registry. See [Auth Related Configuration](/cli/v11/configuring-npm/npmrc#auth-related-configuration)
31
32
When the default registry is used in a package-lock or shrinkwrap it has the special meaning of "the currently configured registry". If you create a lock file while using the default registry you can switch to another registry and npm will install packages from the new registry, but if you create a lock file while using a custom registry packages will be installed from that registry even after you change to another registry.
content/cli/v11/using-npm/scripts.mdx
+15
-1
@@ -218,6 +218,21 @@ Reasons for a package removal include:
218
219
Due to the lack of necessary context, `uninstall` lifecycle scripts are not implemented and will not function.
220
221
+### Working Directory for Scripts
222
+
223
+Scripts are always run from the root of the package folder, regardless of what the current working directory is when `npm` is invoked. This means your scripts can reliably assume they are running in the package root.
224
+
225
+If you want your script to behave differently based on the directory you were in when you ran `npm`, you can use the `INIT_CWD` environment variable, which holds the full path you were in when you ran `npm run`.
226
+
227
+#### Historical Behavior in Older npm Versions
228
+
229
+For npm v6 and earlier, scripts were generally run from the root of the package, but there were rare cases and bugs in older versions where this was not guaranteed. If your package must support very old npm versions, you may wish to add a safeguard in your scripts (for example, by checking process.cwd()).
230
+
231
+For more details, see:
232
+
233
+- [npm v7 release notes](https://github.com/npm/cli/releases/tag/v7.0.0)
234
+- [Discussion about script working directory reliability in npm v6 and earlier](https://github.com/npm/npm/issues/12356)
235
+
236
### User
237
238
When npm is run as root, scripts are always run with the effective uid and gid of the working directory owner.
@@ -302,7 +317,6 @@ Note that these script files don't have to be Node.js or even JavaScript program
317
- Inspect the env to determine where to put things. For instance, if the `npm_config_binroot` environment variable is set to `/home/user/bin`, then don't try to install executables into `/usr/local/bin`. The user probably set it up that way for a reason.
318
- Don't prefix your script commands with "sudo". If root permissions are required for some reason, then it'll fail with that error, and the user will sudo the npm command in question.
319
- Don't use `install`. Use a `.gyp` file for compilation, and `prepare` for anything else. You should almost never have to explicitly set a preinstall or install script. If you are doing this, please consider if there is another option. The only valid use of `install` or `preinstall` scripts is for compilation which must be done on the target architecture.
305
-- Scripts are run from the root of the package folder, regardless of what the current working directory is when `npm` is invoked. If you want your script to use different behavior based on what subdirectory you're in, you can use the `INIT_CWD` environment variable, which holds the full path you were in when you ran `npm run`.
320
321
### See Also
322
content/nav.yml
+1
-1
@@ -1594,7 +1594,7 @@
1594
- title: Changelog
1595
url: /cli/v10/using-npm/changelog
1596
description: Changelog notes for each version
1597
- - title: Version 11.4.0
1597
+ - title: Version 11.4.1
1598
shortName: v11
1599
url: /cli/v11
1600
default: true