Reputation: 578
FROM node:12-alpine
RUN mkdir /project-api
WORKDIR /project-api
RUN apk add --update-cache python
ENV PYTHON=/usr/local/bin/
COPY ./package.json .
RUN npm cache clean --force
RUN rm -rf ~/.npm
RUN rm -rf node_modules
RUN rm -f package-lock.json
RUN npm install
EXPOSE 3000
I was trying to create a node container for my project, but it throws some error while npm install (bcrypt package). I tried installing python in image file.But still it shows error. I'm attaching error screen
Upvotes: 0
Views: 3010
Reputation: 3721
The bcrypt
npm package depends on non-javascript code. This means it needs to be built for the specific architecture it's being run on. The initial "WARNING: Tried to download" indicates a pre-built artifact wasn't available, so it's falling back to building from source.
The specific error I see is Error: not found: make
, which indicates make
isn't installed on the image you're building on (node:12-alpine
). Either install it in a prior step in your dockerfile, or switch to a base image that has it pre-installed (node:12
might).
The bcrypt
package have more specific instructions at https://github.com/kelektiv/node.bcrypt.js/wiki/Installation-Instructions#alpine-linux-based-images.
You need the following packages:
- build-base
- python
apk --no-cache add --virtual builds-deps build-base python
Upvotes: 2