From d8fa9fa5e44d91e1c0170628d4839f7802c65a7f Mon Sep 17 00:00:00 2001 From: Gar Date: Tue, 22 Feb 2022 11:58:19 -0800 Subject: [PATCH] docs: explain $INIT_CWD on using scripts page (#4436) --- docs/content/using-npm/scripts.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/content/using-npm/scripts.md b/docs/content/using-npm/scripts.md index a3fa868f6a61c..7df289b3bd6bd 100644 --- a/docs/content/using-npm/scripts.md +++ b/docs/content/using-npm/scripts.md @@ -344,6 +344,11 @@ file. 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. +* 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`. ### See Also