3

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

npm install 

...

> padlock@2.0.0-beta.1 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.

Kent Shikama
  • 3,910
  • 3
  • 22
  • 55

2 Answers2

4

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

Robo
  • 992
  • 4
  • 10
3

I was able to work around a similar situation by creating this file in my project directory:

$ cat .npmrc

script-shell=/bin/bash

FWIW, the issue I stumbled upon was relying on bash-specific "curly-brace expansion" commands in the postinstall section of the package.json file for the offending module. That malformed command works in MacOS, but not Linux.

MarkHu
  • 1,694
  • 16
  • 29