Skip to content
Advertisement

Heroku buildpack: permission denied on npm install in bash script

I am creating a Heroku build pack and getting an npm permission denied when deploying with the build pack. Here’s the error from the build logs, permission denied when running npm install:

remote: /tmp/buildpack_47ff480d86444378a118f5abcd37cc34/bin/compile:       
35: /tmp/tools/npm: Permission denied

I am packaging npm in a tar.gz and using that.

In my compile file:

#!/bin/sh

export BUILD_DIR=$1
export CACHE_DIR=$2
export ENV_DIR=$3

export TOOLS_URL="https://s3.amazonaws.com/heroku-hzhu/tools.tar.gz"
export TOOLS_DIR="/tmp/tools"

#---- install pre-built tools from tarball ---------------------------------

curl -o $(dirname ${TOOLS_DIR})/tools.tar.gz ${TOOLS_URL}
(cd $(dirname ${TOOLS_DIR}) ; tar -xzvf tools.tar.gz; rm -f  tools.tar.gz)

# add node and npm to path
export NODE_HOME=${TOOLS_DIR}/node-v0.10.29-linux-x64
export PATH=${PATH}:${NODE_HOME}/bin

export NPM_HOME=${TOOLS_DIR}/npm
export PATH=${PATH}:${NPM_HOME}/bin

#---- compile app --------------------------------------------------------------

(cd ${BUILD_DIR} ; ${TOOLS_DIR}/lein cljsbuild once dev)

#---- install node packages ----------------------------------------------------

(cd ${BUILD_DIR} ; ${TOOLS_DIR}/npm install)

Advertisement

Answer

Is it possible that either npm or node is missing the executable bit either when you package them up or when you untar them? That’s what this “permission denied” error looks like to me.

Can you test this locally at all?

Also, are you depending on node 0.10.29 for a particular reason? I ask because the latest stable node is 0.10.36 and it contains some important security fixes. (They may not affect you, though.)

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement