It works!
$ npm test
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm info pretest [email protected]
npm info test [email protected]
> [email protected] test /Users/charlie/Experimental/npm-scripts-envvar
> THIS_WORKS=test node index.js
process.env.THIS_WORKS=test
npm info posttest [email protected]
npm info ok