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
Copy file name to clipboardExpand all lines: content/cli/v11/commands/npm-ls.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,7 +52,7 @@ Note: to get a "bottoms up" view of why a given package is included in the tree
52
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:
Copy file name to clipboardExpand all lines: content/cli/v11/using-npm/registry.mdx
-2Lines changed: 0 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,8 +27,6 @@ You can configure npm to use any compatible registry you like, and even run your
27
27
28
28
npm's package registry implementation supports several write APIs as well, to allow for publishing packages and managing user account information.
29
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
-
32
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)
33
31
34
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.
Copy file name to clipboardExpand all lines: content/cli/v11/using-npm/scripts.mdx
+15-1Lines changed: 15 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -218,6 +218,21 @@ Reasons for a package removal include:
218
218
219
219
Due to the lack of necessary context, `uninstall` lifecycle scripts are not implemented and will not function.
220
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()).
-[Discussion about script working directory reliability in npm v6 and earlier](https://github.com/npm/npm/issues/12356)
235
+
221
236
### User
222
237
223
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
302
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.
303
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.
304
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`.
0 commit comments