Skip to content

Commit

Permalink
run-script: change default for --scripts-prepend-node-path to `warn…
Browse files Browse the repository at this point in the history
…-only`

Change the default behaviour of npm to never prepending the
current node executable’s directory to `PATH` but printing a warning
in the cases in which it previously did.

PR-URL: npm/npm#13409
Credit: @addaleax
Reviewed-By: @zkat
Reviewed-By: @othiym23
  • Loading branch information
addaleax authored and zkat committed Oct 19, 2016
1 parent 3fb1eb3 commit 70b352c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions doc/cli/npm-run-script.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ you should write:
instead of `"scripts": {"test": "node_modules/.bin/tap test/\*.js"}` to run your tests.

`npm run` sets the `NODE` environment variable to the `node` executable with
which `npm` is executed. Also, the directory within which it resides is added to the
`PATH`, if the `node` executable is not in the `PATH`. This behaviour can be
overridden by running `npm` with the `--scripts-prepend-node-path` flag.
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.
Expand Down
2 changes: 1 addition & 1 deletion doc/misc/npm-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ of packages specified according to the pattern `@organization/package`.

### scripts-prepend-node-path

* Default: "auto"
* Default: "warn-only"
* Type: Boolean, `"auto"` or `"warn-only"`

If set to `true`, add the directory in which the current `node` executable
Expand Down
2 changes: 1 addition & 1 deletion lib/config/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ Object.defineProperty(exports, 'defaults', {get: function () {
'save-optional': false,
'save-prefix': '^',
scope: '',
'scripts-prepend-node-path': 'auto',
'scripts-prepend-node-path': 'warn-only',
searchopts: '',
searchexclude: null,
searchstaleness: 15 * 60,
Expand Down

0 comments on commit 70b352c

Please sign in to comment.