简体   繁体   中英

Composing a docker image but getting an npm ERR! EXDEV

I'm developing an API for a small personal project and today I ran into this problem when I try to compose the docker container.

Error code

npm ERR! code EXDEV
npm ERR! syscall rename
npm ERR! path /usr/src/app/node_modules/aproba
npm ERR! dest /usr/src/app/node_modules/.aproba-zsSvSz54
npm ERR! errno -18
npm ERR! EXDEV: cross-device link not permitted, rename '/usr/src/app/node_modules/aproba' -> '/usr/src/app/node_modules/.aproba-zsSvSz54'

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-11-21T15_33_05_552Z-debug.log
ERROR: Service 'api-backend' failed to build : The command '/bin/sh -c npm install' returned a non-zero code: 238

Previously today (21-11-2020) everything have worked fine. But when I tried to use Bcrypt I started getting errors. After a while I rolled back and all of a sudden I got this error. I will link my docker-compose and docker file down below.

dockerfile:

FROM node

WORKDIR /usr/src/app

ENV DB_HOST=api-db \
    DB_PORT=${DB_PORT} \
    DB_DATABASE=${DB_DATABASE} \
    DB_USERNAME=${DB_USERNAME} \
    DB_PASSWORD=${DB_PASSWORD}

COPY package*.json ./

RUN npm install
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y postgresql-client  

COPY docker-entrypoint /usr/local/bin/
RUN sed -i -e 's/\r$//' /usr/local/bin/docker-entrypoint && chmod +x /usr/local/bin/docker-entrypoint
ENTRYPOINT [ "docker-entrypoint" ]

EXPOSE 8888

docker-compose:

version: "3.8"

services:

  api-backend:
    image: node
    build: .
    hostname: backend
    env_file:
      - .env
    ports:
      - 3000:3000
    volumes:
      - .:/usr/src/app
    restart: on-failure:3
    depends_on:
      - api-db

  api-db:
    image: postgres
    hostname: api-db
    environment:
      - POSTGRES_DB=${DB_DATABASE}
      - POSTGRES_USER=${DB_USER}
      - POSTGRES_PASSWORD=${DB_PASSWORD}
    ports:
      - 2345:5432
    volumes: 
      - ./migrations:/docker-entrypoint-initdb.d
    restart: on-failure:3

networks:
  default:
    external:
      name: ${NETWORK:-local}

docker-entrypoint

#!/bin/bash

# waits for a database to come up
wait_for_db() {
    local host="$1" port="$2" user="$3" password="$4" name="$5"

    local psql=(psql postgres -p "$port" -U "$user" --password="$password" "$5")

    echo "[db] not yet ready to accept connections"
    WAIT_FOR_PG_ISREADY="while ! pg_isready; do sleep 1; done;"
    docker-compose exec postgres bash -c "$WAIT_FOR_PG_ISREADY"
    echo "[db] ready to accept connections"

}

wait_for_db "$DB_HOST" "$DB_PORT" "$DB_USERNAME" "$DB_PASSWORD" "$DB_DATABASE" || exit 0

npm run dev #app.js

I tried running with FROM node:14.15 instead and that seems to work. So probably something to do with the latest node image.

使用像FROM node:14.15这样的特定节点图像而不是一般的FROM node工作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM