Running bash scripts with npm Running bash scripts with npm shell shell

Running bash scripts with npm


Its totally possible...

"scripts": {   "build": "./build.sh"},

also, make sure you put a hash bang at the top of your bash file #!/usr/bin/env bash

also make sure you have permissions to execute the file

chmod +x ./build.sh

Finally, the command to run build in npm would be

npm run build


If you don't want to bother with giving permissions and the env you execute the script has for example sh, you could just do

"scripts": {   "build": "sh ./build.sh"}


Even Simpler:

I routinely do this for one-offs and PoC's not involving a VCS

package.json
{    "scripts": {        "ship": "rsync -avz deployable/* <some-server>:/var/www/some-site/sub-dir/"    },}...