-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Description
Is there an existing issue for this?
- I have searched the existing issues
This is a CLI Docs Enhancement, not another kind of Docs Enhancement.
- This is a CLI Docs Enhancement.
Description of Problem
I was unable to prove whether npm v7 scripts can expect to be run in the top level of their package directory in all circumstances.
Potential Solution
I'm glad to see that the current (npm v11) docs now seem to give an authoritative guarantee about the working directory for scripts to be run: https://docs.npmjs.com/cli/v11/using-npm/scripts/#best-practices
However, "Scripts are run from the root of the package folder" is a description of what npm does. It seems a bit misplaced in a chapter "Best practices", where I'd expect things I can and should do, but can opt to misbehave. I do see that this information is required for the next sentences to make sense, but that info is worthy in itself, there's no need to bury it here.
I think we should move that up a lot, at least up to the "User" or "Environment" chapters, probably even before "User".
Also it would be nice to have an overview (maybe as a link to an external page) of how earlier versions of npm were expected to behave in regards to the working directory, and how reliable it was. That would give an easy authoritative source on how much path verification code is justified in scripts.