I am trying to install nvm
which requires you to source a file
I found that this does not work:
RUN . /root/.nvm/nvm.sh
RUN nvm use
Says nvm
not found
But this does work:
RUN . /root/.nvm/nvm.sh && nvm use
Any idea how I can persist the sourcing of the nvm.sh
file across
RUN commands?
My full set of commands
# Persist NVM
RUN mkdir /root/.nvm
ENV NVM_DIR /root/.nvm
ENV NODE_VERSION 9.11.2
ENV NODE_PATH $NVM_DIR/versions/node/v$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
# NVM So that we can get the latest node
# @todo Fix this to not require sourcing in the same step @tolicodes and should happen in main Dockerfile
RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
RUN . $NVM_DIR/nvm.sh && \
nvm install $NODE_VERSION && \
nvm alias default $NODE_VERSION && \
nvm use default
The main thing is the ENV
variables. Other instructions get the path incorrect for the latest nvm.