Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker - NPM install local packages

Tags:

node.js

docker

I am currently trying to install my NPM packages with Docker however, it's unable to do this for local packages? How do I fix this?

DockerFile:

FROM node:12

WORKDIR /var/api

COPY package*.json ./

RUN npm install

COPY . .

EXPOSE 3010

CMD ["npm", "start"]

package.json

  "dependencies": {
    "@hapi/joi": "^16.1.7",
    "@polka/send-type": "^0.5.2",
    "polka": "^0.5.2",
    "body-parser": "^1.19.0",
    "axios": "^0.19.0",
    "core": "file:../core",
    "compression": "^1.7.4",
    "cors": "^2.8.5",
    "dotenv": "^8.2.0",
    "ua-parser-js": "^0.7.21",
    "moment": "^2.24.0",
    "moment-duration-format": "^2.3.2",
    "node-schedule": "^1.3.2"
  },

Thanks.

like image 424
user12869402 Avatar asked Sep 13 '25 22:09

user12869402


1 Answers

COPY package*.json ./

RUN npm install

The problem is with those two lines, you are trying to install "core": "file:../core" but you never copied those dependencies to your image, so copy those dependencies along with the package.json and you will be good

like image 198
Hesham Adel Avatar answered Sep 15 '25 13:09

Hesham Adel