Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
845 views
in Technique[技术] by (71.8m points)

node.js - 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
From node

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

use

FROM node:lts

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share

2.1m questions

2.1m answers

63 comments

56.7k users

...