isaacs/npm — Issue #1625: The "|| true" install script trick doesn't work on Windows
Author: chowey
Created: 2011-10-29 03:36:43+00:00
State: open

There seem to be a number of projects that have install scripts that look something like:

"scripts" : {
"install" : "node-waf configure build || true"
}

In the above, the `|| true` (I believe) is so that, even if `node-waf` doesn't exist and the shell reports an error, the `|| true` reports success. Then npm can install successfully even if `node-waf` isn't on the user's computer (probably a good bet on Windows using the pre-built binary).

However, on Windows, the `|| true` seems to attempt to run a command called `true` from the shell. I believe this is abnormal behavior.

An example of a package that fails is `pg` (try `npm install pg`). This gives me the following error response:

c:\node>npm install pg

> pg@0.6.3 install c:\node\node_modules\pg
> node-waf configure build || true

'node-waf' is not recognized as an internal or external command,
operable program or batch file.
'true' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! error installing pg@0.6.3 Error: pg@0.6.3 install: `node-waf configure
build || true`
npm ERR! error installing pg@0.6.3 `cmd "/c" "node-waf configure build || true"`
failed with 1
npm ERR! error installing pg@0.6.3 at ChildProcess. (c:\node\node
_modules\npm\lib\utils\exec.js:49:20)
npm ERR! error installing pg@0.6.3 at ChildProcess.emit (events.js:70:17)
npm ERR! error installing pg@0.6.3 at maybeExit (child_process.js:336:16)
npm ERR! error installing pg@0.6.3 at Process.onexit (child_process.js:371:5
)
npm ERR! pg@0.6.3 install: `node-waf configure build || true`
npm ERR! `cmd "/c" "node-waf configure build || true"` failed with 1
npm ERR!
npm ERR! Failed at the pg@0.6.3 install script.
npm ERR! This is most likely a problem with the pg package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-waf configure build || true
npm ERR! You can get their info via:
npm ERR! npm owner ls pg
npm ERR! There is likely additional logging output above.
npm ERR!
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "c:\\node\\\\node.exe" "c:\\node\\node_modules\\npm\\bin\\npm-c
li.js" "install" "pg"
npm ERR! cwd c:\node
npm ERR! node -v v0.5.10
npm ERR! npm -v 1.0.103
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! c:\node\npm-debug.log
npm not ok