How to install nvm in docker?

后端 未结 14 946
陌清茗
陌清茗 2020-12-04 05:53

I am in the process of building a new Docker image and I\'m looking to get NVM installed so I can manage nodejs.

Reading the docs on how to install NVM they mention

14条回答
  •  爱一瞬间的悲伤
    2020-12-04 06:35

    Nvm paths have changed since the accepted answer, so if you want to use a more up-to-date nvm version, you need to make a few changes. Also, it is not necessary to remap sh to make it work:

    ENV NVM_DIR /usr/local/nvm
    RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash
    ENV NODE_VERSION v7.9.0
    RUN /bin/bash -c "source $NVM_DIR/nvm.sh && nvm install $NODE_VERSION && nvm use --delete-prefix $NODE_VERSION"
    
    ENV NODE_PATH $NVM_DIR/versions/node/$NODE_VERSION/lib/node_modules
    ENV PATH      $NVM_DIR/versions/node/$NODE_VERSION/bin:$PATH
    

    Not sure if you will need the --delete-prefix option on the nvm use - I did, but that may be something strange about my base image.

提交回复
热议问题