Skip to content

Commit d8fa9fa

Browse files
authored
docs: explain $INIT_CWD on using scripts page (#4436)
1 parent c9ff797 commit d8fa9fa

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

docs/content/using-npm/scripts.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,11 @@ file.
344344
preinstall or install script. If you are doing this, please consider if
345345
there is another option. The only valid use of `install` or `preinstall`
346346
scripts is for compilation which must be done on the target architecture.
347+
* Scripts are run from the root of the package folder, regardless of what the
348+
current working directory is when `npm` is invoked. If you want your
349+
script to use different behavior based on what subdirectory you're in, you
350+
can use the `INIT_CWD` environment variable, which holds the full path you
351+
were in when you ran `npm run`.
347352

348353
### See Also
349354

0 commit comments

Comments
 (0)