Skip to content

Commit

Permalink
fix(node): npm install for root (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice authored Oct 20, 2021
1 parent 9ade6d5 commit fbb7af1
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/usr/local/bin/install-npm
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/usr/local/bin/install-tool
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions src/usr/local/buildpack/tools/node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions src/usr/local/buildpack/tools/npm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions src/usr/local/buildpack/tools/pnpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions src/usr/local/buildpack/tools/yarn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions test/node/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
#--------------------------------------
Expand Down

0 comments on commit fbb7af1

Please sign in to comment.