From b98569a8ca28dbd611fe84492aee996e2e567b55 Mon Sep 17 00:00:00 2001 From: isaacs Date: Thu, 17 Dec 2020 15:55:37 -0800 Subject: [PATCH] docs: add note about INIT_CWD to run-script doc --- docs/content/commands/npm-run-script.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/content/commands/npm-run-script.md b/docs/content/commands/npm-run-script.md index 05f6380c2b326..b7ab20a73af47 100644 --- a/docs/content/commands/npm-run-script.md +++ b/docs/content/commands/npm-run-script.md @@ -60,18 +60,18 @@ on Unix-like systems it is the `/bin/sh` command, on Windows it is the `cmd.exe` The actual shell referred to by `/bin/sh` also depends on the system. You can customize the shell with the `script-shell` configuration. -Scripts are run from the root of the module, regardless of what the current -working directory is when `npm run` is called. 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`. - -`npm run` sets the `NODE` environment variable to the `node` executable with -which `npm` is executed. Also, if the `--scripts-prepend-node-path` is passed, -the directory within which `node` resides is added to the -`PATH`. If `--scripts-prepend-node-path=auto` is passed (which has been the -default in `npm` v3), this is only performed when that `node` executable is -not found in the `PATH`. +Scripts are run from the root of the package folder, regardless of what the +current working directory is when `npm run` is called. 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`. + +`npm run` sets the `NODE` environment variable to the `node` executable +with which `npm` is executed. Also, if the `--scripts-prepend-node-path` is +passed, the directory within which `node` resides is added to the `PATH`. +If `--scripts-prepend-node-path=auto` is passed (which has been the default +in `npm` v3), this is only performed when that `node` executable is not +found in the `PATH`. If you try to run a script without having a `node_modules` directory and it fails, you will be given a warning to run `npm install`, just in case you've forgotten.