Home > Enterprise >  Install Latest NPM Version in Dockerfile
Install Latest NPM Version in Dockerfile

Time:07-15

I am trying to upgrade npm to the latest version in a Dockerfile, but I cannot run npm install -g npm@latest.

Dockerfile:

FROM debian:bullseye
ENV DEBIAN_FRONTEND noninteractive
ENV CONDA_DIR /opt/conda

# Core installs
RUN apt-get update && \
    apt-get upgrade && \
    apt-get install -y git vim wget build-essential python3 ca-certificates bzip2 libsm6 npm nodejs && \
    apt-get clean

RUN npm install -g npm@latest

The error output I get is:

[ ] Building 9.7s (7/24)                                                                                                                                                
 => [internal] load build definition from Dockerfile                                                                                                               0.0s
 => => transferring dockerfile: 1.89kB                                                                                                                             0.0s
 => [internal] load .dockerignore                                                                                                                                  0.0s
 => => transferring context: 2B                                                                                                                                    0.0s
 => [internal] load metadata for docker.io/library/debian:jessie                                                                                                   0.7s
 => [internal] load build context                                                                                                                                  0.0s
 => => transferring context: 292B                                                                                                                                  0.0s
 => [ 1/20] FROM docker.io/library/debian:jessie@sha256:32ad5050caffb2c7e969dac873bce2c370015c2256ff984b70c1c08b3a2816a0                                           0.0s
 => CACHED [ 2/20] RUN apt-get update &&     apt-get upgrade &&     apt-get install -y git vim wget build-essential python3 ca-certificates bzip2 libsm6 npm node  0.0s
 => ERROR [ 3/20] RUN npm install -g npm@latest                                                                                                                    8.9s
------                                                                                                                                                                  
 > [ 3/20] RUN npm install -g npm@latest:                                                                                                                               
#6 3.917 npm WARN engine [email protected]: wanted: {"node":"^12.13.0 || ^14.15.0 || >=16"} (current: {"node":"0.10.29","npm":"1.4.21"})                                       
#6 8.272 npm WARN package.json [email protected] No README data                                                                                                              
#6 8.274 npm WARN package.json [email protected] No README data                                                                                                          
#6 8.274 npm WARN package.json [email protected] No README data                                                                                                      
#6 8.275 npm WARN package.json [email protected] No README data
#6 8.275 npm WARN package.json [email protected] No README data
#6 8.276 npm WARN package.json [email protected] No README data
#6 8.278 npm WARN package.json [email protected] No README data
#6 8.279 npm WARN package.json [email protected] No README data
#6 8.279 npm WARN package.json [email protected] No README data
#6 8.280 npm WARN package.json [email protected] No README data
#6 8.280 npm WARN package.json [email protected] No README data
#6 8.281 npm WARN package.json [email protected] No README data
#6 8.281 npm WARN package.json [email protected] No README data
#6 8.281 npm WARN package.json [email protected] No README data
#6 8.282 npm WARN package.json [email protected] No README data
#6 8.283 npm WARN package.json [email protected] No README data
#6 8.284 npm WARN package.json [email protected] No README data
#6 8.285 npm WARN package.json [email protected] No README data
#6 8.286 npm WARN package.json [email protected] No README data
#6 8.286 npm WARN package.json [email protected] No README data
#6 8.287 npm WARN package.json [email protected] No README data
#6 8.287 npm WARN package.json [email protected] No README data
#6 8.288 npm WARN package.json [email protected] No README data
#6 8.289 npm WARN package.json [email protected] No README data
#6 8.290 npm WARN package.json [email protected] No README data
#6 8.290 npm WARN package.json [email protected] No README data
#6 8.292 npm WARN package.json [email protected] No README data
#6 8.294 npm WARN package.json [email protected] No README data
#6 8.294 npm WARN package.json [email protected] No README data
#6 8.295 npm WARN package.json [email protected] No README data
#6 8.295 npm WARN package.json [email protected] No README data
#6 8.296 npm WARN package.json [email protected] No README data
#6 8.297 npm WARN package.json [email protected] No README data
#6 8.297 npm WARN package.json [email protected] No README data
#6 8.298 npm WARN package.json [email protected] No README data
#6 8.298 npm WARN package.json [email protected] No README data
#6 8.299 npm WARN package.json [email protected] No README data
#6 8.300 npm WARN package.json [email protected] No README data
#6 8.300 npm WARN package.json [email protected] No README data
#6 8.301 npm WARN package.json [email protected] No README data
#6 8.301 npm WARN package.json [email protected] No README data
#6 8.302 npm WARN package.json [email protected] No README data
#6 8.303 npm WARN package.json [email protected] No README data
#6 8.303 npm WARN package.json [email protected] No README data
#6 8.304 npm WARN package.json [email protected] No README data
#6 8.312 npm WARN package.json [email protected] No README data
#6 8.312 npm WARN package.json [email protected] No README data
#6 8.313 npm WARN package.json [email protected] No README data
#6 8.313 npm WARN package.json [email protected] No README data
#6 8.314 npm WARN package.json [email protected] No description
#6 8.314 npm WARN package.json [email protected] No README data
#6 8.315 npm WARN package.json [email protected] No README data
#6 8.315 npm WARN package.json [email protected] No README data
#6 8.316 npm WARN package.json [email protected] No README data
#6 8.316 npm WARN package.json [email protected] No README data
#6 8.317 npm WARN package.json [email protected] No README data
#6 8.317 npm WARN package.json [email protected] No README data
#6 8.318 npm WARN package.json [email protected] No README data
#6 8.318 npm WARN package.json [email protected] No README data
#6 8.319 npm WARN package.json [email protected] No README data
#6 8.321 npm WARN package.json [email protected] No README data
#6 8.321 npm WARN package.json [email protected] No README data
#6 8.321 npm WARN package.json [email protected] No README data
#6 8.322 npm WARN package.json [email protected] No repository field.
#6 8.322 npm WARN package.json [email protected] No README data
#6 8.323 npm WARN package.json [email protected] No README data
#6 8.324 npm WARN package.json [email protected] No README data
#6 8.324 npm WARN package.json [email protected] No README data
#6 8.325 npm WARN package.json [email protected] No README data
#6 8.325 npm WARN package.json [email protected] No repository field.
#6 8.325 npm WARN package.json [email protected] No README data
#6 8.326 npm WARN package.json [email protected] No README data
#6 8.326 npm WARN package.json [email protected] No README data
#6 8.327 npm WARN package.json [email protected] No README data
#6 8.327 npm WARN package.json [email protected] No README data
#6 8.328 npm WARN package.json [email protected] No README data
#6 8.328 npm WARN package.json [email protected] No README data
#6 8.329 npm WARN package.json [email protected] No README data
#6 8.329 npm WARN package.json [email protected] No README data
#6 8.330 npm WARN package.json [email protected] No README data
#6 8.330 npm WARN package.json [email protected] No README data
#6 8.331 npm WARN package.json [email protected] No README data
#6 8.331 npm WARN package.json [email protected] No README data
#6 8.331 npm WARN package.json [email protected] No README data
#6 8.332 npm WARN package.json [email protected] No README data
#6 8.332 npm WARN package.json [email protected] No README data
#6 8.333 npm WARN package.json [email protected] No README data
#6 8.333 npm WARN package.json [email protected] No README data
#6 8.334 npm WARN package.json [email protected] No README data
#6 8.334 npm WARN package.json [email protected] No README data
#6 8.335 npm WARN package.json [email protected] No README data
#6 8.335 npm WARN package.json [email protected] No README data
#6 8.335 npm WARN package.json [email protected] No repository field.
#6 8.336 npm WARN package.json [email protected] No README data
#6 8.336 npm WARN package.json [email protected] No README data
#6 8.337 npm WARN package.json [email protected] No README data
#6 8.338 npm WARN package.json [email protected] No README data
#6 8.339 npm WARN package.json [email protected] No README data
#6 8.340 npm WARN package.json [email protected] No README data
#6 8.340 npm WARN package.json [email protected] No README data
#6 8.340 npm WARN package.json [email protected] No README data
#6 8.341 npm WARN package.json [email protected] No README data
#6 8.341 npm WARN package.json [email protected] No README data
#6 8.342 npm WARN package.json [email protected] No README data
#6 8.342 npm WARN package.json [email protected] No README data
#6 8.343 npm WARN package.json [email protected] No README data
#6 8.343 npm WARN package.json [email protected] No README data
#6 8.344 npm WARN package.json [email protected] No README data
#6 8.344 npm WARN package.json [email protected] No README data
#6 8.345 npm WARN package.json [email protected] No README data
#6 8.345 npm WARN package.json [email protected] No README data
#6 8.346 npm WARN package.json [email protected] No README data
#6 8.346 npm WARN package.json [email protected] No README data
#6 8.347 npm WARN package.json [email protected] No README data
#6 8.347 npm WARN package.json [email protected] No README data
#6 8.348 npm WARN package.json [email protected] No README data
#6 8.348 npm WARN package.json [email protected] No README data
#6 8.349 npm WARN package.json [email protected] No README data
#6 8.349 npm WARN package.json [email protected] No README data
#6 8.350 npm WARN package.json [email protected] No README data
#6 8.350 npm WARN package.json [email protected] No README data
#6 8.351 npm WARN package.json [email protected] No README data
#6 8.352 npm WARN package.json [email protected] No README data
#6 8.352 npm WARN package.json [email protected] No README data
#6 8.352 npm WARN package.json [email protected] No README data
#6 8.353 npm WARN package.json [email protected] No README data
#6 8.354 npm WARN package.json [email protected] No README data
#6 8.354 npm WARN package.json [email protected] No README data
#6 8.355 npm WARN package.json [email protected] No README data
#6 8.355 npm WARN package.json [email protected] No README data
#6 8.365 npm WARN package.json [email protected] No README data
#6 8.819 npm ERR! Error: Method Not Allowed
#6 8.819 npm ERR!     at errorResponse (/usr/share/npm/lib/cache/add-named.js:260:10)
#6 8.819 npm ERR!     at /usr/share/npm/lib/cache/add-named.js:203:12
#6 8.819 npm ERR!     at saved (/usr/share/npm/node_modules/npm-registry-client/lib/get.js:167:7)
#6 8.820 npm ERR!     at Object.oncomplete (fs.js:107:15)
#6 8.820 npm ERR! If you need help, you may report this *entire* log,
#6 8.820 npm ERR! including the npm and node versions, at:
#6 8.821 npm ERR!     <http://github.com/npm/npm/issues>
#6 8.822 
#6 8.822 npm ERR! System Linux 5.10.104-linuxkit
#6 8.823 npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "npm@latest"
#6 8.823 npm ERR! cwd /
#6 8.823 npm ERR! node -v v0.10.29
#6 8.823 npm ERR! npm -v 1.4.21
#6 8.824 npm ERR! code E405
#6 8.841 npm ERR! 
#6 8.842 npm ERR! Additional logging details can be found in:
#6 8.843 npm ERR!     /npm-debug.log
#6 8.843 npm ERR! not ok code 0
------
executor failed running [/bin/sh -c npm install -g npm@latest]: exit code: 1

How can I get the latest npm version?

CodePudding user response:

This could be a follow-up issue because something earlier went wrong. Try to build with --no-cache option and look closely to the output log.

  • Related