Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change shell of npm install

I'm trying to npm install a package in Ubuntu 16.04. I get the following error message:

npm install 

...

> [email protected] bower-install /home/kent/Documents/padlock
> pushd app && bower install && popd app

sh: 1: pushd: not found

My Research

According to /bin/sh: pushd: not found, my problem is clearly that npm install is trying to execute pushd with sh not bash.

However, my default shell is already bash

$ env | grep SHELL
SHELL=/bin/bash
$ echo $SHELL
/bin/bash
$ echo $0
bash

and I'm not sure what I need to change. I've also tried adding SHELL=/bin/bash before I execute pushd app but I have had no luck with that either.

like image 332
Kent Shikama Avatar asked Oct 21 '25 14:10

Kent Shikama


1 Answers

npm-scripts run using sh

Scripts are run by passing the line as a script argument to sh

https://docs.npmjs.com/misc/scripts#exiting

If you want to use bash for your scripts make the script

bash -c 'pushd app && bower install && popd'

Update: As of November 2017 you can now set script-shell in .npmrc to use a custom shell

like image 184
Robo Avatar answered Oct 24 '25 05:10

Robo