From 70b352c6db41533b9a4bfaa9d91f7a2a1178f74e Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Thu, 1 Sep 2016 21:54:29 +0200 Subject: [PATCH] run-script: change default for `--scripts-prepend-node-path` to `warn-only` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: https://github.com/npm/npm/pull/13409 Credit: @addaleax Reviewed-By: @zkat Reviewed-By: @othiym23 --- doc/cli/npm-run-script.md | 8 +++++--- doc/misc/npm-config.md | 2 +- lib/config/defaults.js | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/doc/cli/npm-run-script.md b/doc/cli/npm-run-script.md index 3a447a35a297b..f1389c21c623f 100644 --- a/doc/cli/npm-run-script.md +++ b/doc/cli/npm-run-script.md @@ -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. diff --git a/doc/misc/npm-config.md b/doc/misc/npm-config.md index 3803cb1143915..9e21a4a3f7582 100644 --- a/doc/misc/npm-config.md +++ b/doc/misc/npm-config.md @@ -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 diff --git a/lib/config/defaults.js b/lib/config/defaults.js index b957f28f59a22..b59c46e7854d0 100644 --- a/lib/config/defaults.js +++ b/lib/config/defaults.js @@ -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,