0

Running npm 3.10.3 and node 6.7.0 on Ubuntu, I was using the "npm-run" package to allow using executable node scripts locally in a cross-platform way. So, for example, for some simple ava tests I ran with the following in package.json.

"scripts": {
  "test": "npm-run ava --serial "
}

However, I noticed that the following worked just fine as well, after verifying that ava was not installed globally:

"scripts": {
   "test": "ava --serial "
}

I haven't tested on Windows yet, so the jury's still out, but does anyone know if this behavior is now supported directly in npm as it appears? If so, is npm-run still recommended for backward compatibility?

Thanks,

John

John Lockwood
  • 3,787
  • 29
  • 27
  • AFAIU `npm-run` package [is solving a slightly different problem](https://github.com/timoxley/npm-run#why) than what you describe - it's not about what is/isn't installed globally, but whether there's an executable created in `./node_modules/.bin` by `npm install`. Having said that, I never knew about the existence of a problem described in `npm-run`'s readme (maybe it's unique to npm3?) and hence never used `npm-run` and I never had any problems due to that. – jakub.g Oct 16 '16 at 22:04
  • Yes, and when all else fails read the manual -- just caught this in the docs for npm scripts (so not sure why folks recommended npm-run): If you depend on modules that define executable scripts, like test suites, then those executables will be added to the PATH for executing the scripts. So, if your package.json has this: { "name" : "foo" , "dependencies" : { "bar" : "0.1.x" } , "scripts": { "start" : "bar ./test" } } then you could run npm start to execute the bar script, which is exported into the node_modules/.bin directory on npm install. – John Lockwood Oct 16 '16 at 22:10

0 Answers0