In which directory does npm postinstall run?

109 Views Asked by At

I am running npm install infojunkie/musicxml-mma#npm-install. That module includes a postinstall script that generates a config file which should contain the absolute path of the installed module.

The postinstall shell script uses $(pwd) to find the current path, which I had assumed would be the installation directory:

sed -r "s#/full/path/to/module#$PWD#" configrc.example > config.rc

However, when I examine the generated config.rc file, I see a temporary directory:

[...] /home/kratib/.npm/_cacache/tmp/git-clonetLJs8x [...]

I am interpreting this to mean that the postinstall script is not running in the final installation directory, but in a temporary one.

How can I ensure that the script will run in the final directory? Is there a later lifecycle event that I can use instead of postinstall?

0

There are 0 best solutions below