diff --git a/src/usr/local/bin/install-npm b/src/usr/local/bin/install-npm index dcd92914c..8ee0739e3 100755 --- a/src/usr/local/bin/install-npm +++ b/src/usr/local/bin/install-npm @@ -8,8 +8,12 @@ require_root require_tool "$@" check_command npm +unset NPM_CONFIG_PREFIX + echo "Installing npm tool ${TOOL_NAME} v${TOOL_VERSION}" -npm install --global ${TOOL_NAME}@${TOOL_VERSION} +npm install --global ${TOOL_NAME}@${TOOL_VERSION} --unsafe # Clean download cache npm cache clean --force +# Clean node-gyp cache +rm -rf /root/.cache diff --git a/src/usr/local/bin/install-tool b/src/usr/local/bin/install-tool index b069437b8..aca0d17d2 100755 --- a/src/usr/local/bin/install-tool +++ b/src/usr/local/bin/install-tool @@ -25,5 +25,5 @@ echo "Installing tool ${TOOL_NAME} v${TOOL_VERSION}" # cleanup if [[ $EUID -eq 0 ]]; then - rm -rf /var/lib/apt/lists/* + rm -rf /var/lib/apt/lists/* /tmp/* fi diff --git a/src/usr/local/buildpack/tools/node.sh b/src/usr/local/buildpack/tools/node.sh index 37c9e76f6..911055ec7 100644 --- a/src/usr/local/buildpack/tools/node.sh +++ b/src/usr/local/buildpack/tools/node.sh @@ -52,3 +52,9 @@ export_env NODE_OPTIONS "--use-openssl-ca" shell_wrapper node shell_wrapper npm + +# Clean download cache +npm cache clean --force + +# Clean node-gyp cache +rm -rf /root/.cache diff --git a/src/usr/local/buildpack/tools/npm.sh b/src/usr/local/buildpack/tools/npm.sh index dee981eca..1322d735e 100644 --- a/src/usr/local/buildpack/tools/npm.sh +++ b/src/usr/local/buildpack/tools/npm.sh @@ -11,3 +11,8 @@ fi npm install -g npm@${TOOL_VERSION} npm --version + +# Clean download cache +npm cache clean --force +# Clean node-gyp cache +rm -rf /root/.cache diff --git a/src/usr/local/buildpack/tools/pnpm.sh b/src/usr/local/buildpack/tools/pnpm.sh index be5fcb687..773a84f82 100644 --- a/src/usr/local/buildpack/tools/pnpm.sh +++ b/src/usr/local/buildpack/tools/pnpm.sh @@ -15,3 +15,8 @@ pnpm --version if [[ $EUID -eq 0 ]]; then shell_wrapper pnpm fi + +# Clean download cache +npm cache clean --force +# Clean node-gyp cache +rm -rf /root/.cache diff --git a/src/usr/local/buildpack/tools/yarn.sh b/src/usr/local/buildpack/tools/yarn.sh index f535d196c..56893e631 100644 --- a/src/usr/local/buildpack/tools/yarn.sh +++ b/src/usr/local/buildpack/tools/yarn.sh @@ -13,3 +13,8 @@ npm install -g yarn@${TOOL_VERSION} yarn --version shell_wrapper yarn + +# Clean download cache +npm cache clean --force +# Clean node-gyp cache +rm -rf /root/.cache diff --git a/test/node/Dockerfile b/test/node/Dockerfile index 386f5e1db..90159922a 100644 --- a/test/node/Dockerfile +++ b/test/node/Dockerfile @@ -33,6 +33,13 @@ RUN set -ex; \ RUN node --version RUN npm --version + +## Test for #136 +USER 0 + +# renovate: datasource=npm +RUN install-npm re2 1.16.0 + #-------------------------------------- # test: yarn #--------------------------------------