You could try the following:
RUN curl -fsSL https://raw.githubusercontent.com/tj/n/master/bin/n | bash -s lts && \ npm install -g npm@latest && \ npm install -g yarn