码头工人:npm ERR! enoent

时间:2020-09-01 01:04:44

标签: node.js docker

你好,我有以下安装泊坞窗:

docker-compose.yml:

version: "3"

services:
  micro-hr:
    build: ./backend/micro-hr
    entrypoint: ./backend/micro-hr/.docker/entrypoint.sh
    container_name: micro-hr
    environment:
      - CHOKIDAR_USEPOLLING=true
    ports:
      - 3001:3000
    volumes:
      - .:/home/node/app

dockerfile:

FROM node:12.14.0-alpine3.11

RUN apk add --no-cache bash git

RUN touch /home/node/.bashrc | echo "PS1='\w\$ '" >> /home/node/.bashrc

RUN npm config set cache /home/node/app/.npm-cache --global

WORKDIR /home/node/app

COPY --chown=node:node . ./

COPY package*.json .env ./

USER node

entrypoint.sh

#!/bin/bash

npm config set cache /home/node/app/.npm-cache --global

cd /home/node/app

npm install
npm run start:dev

但是我在docker-compose up上遇到了这个错误:

micro-hr              | npm WARN saveError ENOENT: no such file or directory, open '/home/node/app/package.json'
micro-hr              | npm WARN enoent ENOENT: no such file or directory, open '/home/node/app/package.json'
micro-hr              | npm WARN app No description
micro-hr              | npm WARN app No repository field.
micro-hr              | npm WARN app No README data
micro-hr              | npm WARN app No license field.
micro-hr              | 
micro-hr              | up to date in 1.154s
micro-hr              | found 0 vulnerabilities
micro-hr              | 
micro-hr              | npm ERR! code ENOENT
micro-hr              | npm ERR! syscall open
micro-hr              | npm ERR! path /home/node/app/package.json
micro-hr              | npm ERR! errno -2
micro-hr              | npm ERR! enoent ENOENT: no such file or directory, open '/home/node/app/package.json'
micro-hr              | npm ERR! enoent This is related to npm not being able to find a file.
micro-hr              | npm ERR! enoent 
micro-hr              | 
micro-hr              | npm ERR! A complete log of this run can be found in:
micro-hr              | npm ERR!     /home/node/app/.npm-cache/_logs/2020-09-01T01_00_33_229Z-debug.log

我怀疑它与节点用户有关,但是我没有进行测试,也没有 我通过docker-compose日志得到了这一点。

1 个答案:

答案 0 :(得分:1)

您的docker-compose.yml说

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
    <overlayable name="Test">
        <policy type="public">
            <item type="xml" name="my_config"/>
        </policy>
    </overlayable>
</resources>    

删除这两行,在本地构建应用程序(不使用Docker),并且仅在部署Docker映像时构建。

有关更多说明,请参见此docker-compose fails to start with npm ERR! enoent ENOENT: no such file or directory, open '/usr/src/app/package.json'