HelloGriffin
HelloGriffin

Reputation: 111

Trying to update NPM in Docker: code EISDIR

I'm trying to update NPM with ["npm","install","-g","npm"] but it says:

Step 4/12 : RUN ["npm", "install", "-g", "npm"]
 ---> Running in 708a95e71771
npm ERR! code EISDIR
npm ERR! syscall copyfile
npm ERR! path /usr/local/lib/node_modules/npm
npm ERR! dest /usr/local/lib/node_modules/.npm-i9nnxROI
npm ERR! errno -21
npm ERR! EISDIR: illegal operation on a directory, copyfile '/usr/local/lib/node_modules/npm' -> '/usr/local/lib/node_modules/.npm-i9nnxROI'

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-12-31T13_38_29_907Z-debug.log
The command 'npm install -g npm' returned a non-zero code: 235

My dockerfile:

FROM node

WORKDIR /root

COPY package*.json ./
RUN ["npm", "install", "-g", "npm"]
RUN ["npm", "audit", "fix"]
RUN ["npm", "install"]

COPY ./*.js ./
COPY static ./static
COPY views ./views

COPY conf.d/* /etc/dashboard/

EXPOSE 80

CMD ["node", "index.js"]

So it looks like /usr/local/lib/node_modules/.npm-i9nnxROI or /usr/local/lib/node_modules/npm is a directory and not a file but I think it should be a directory.

On my system (Linux 5.10.2-2-MANJARO #1 SMP PREEMPT x86_64 GNU/Linux) it works but on my server (Linux 5.4.0-58-generic #64-Ubuntu SMP x86_64 x86_64 x86_64 GNU/Linux) it doesn't.

Upvotes: 2

Views: 1372

Answers (1)

PDHide
PDHide

Reputation: 19979

From node

installs latest node , which has npm version 7+ . Its not stable has some issues

use

FROM node:lts

Upvotes: 3

Related Questions