Facing error on installation of Strapi . " Something went wrong installing the "sharp" module"

@eventyret the docs doesn’t mention sharp. Or at least the search gives no result for sharp. That is what I meant.

1 Like

try commands
npm config set strict-ssl false
NODE_TLS_REJECT_UNAUTHORIZED=0

to shut down tls certificats verification

heh it’s worked for my provider on test account but not for my real enviroment.
i guess, i should go for wordpress solutions))

heh. We went out of RAM. so check your usage of ram also))

I had the same error when I put my Strapi instance inside Docker container. I had to add this line /server/node_modules to the volumes section of docker compose configuration and it worked

1 Like

It’s very bad practice to share node_modules with a container.
The error is normally because sharp and build tools are not installed.

On Alpine with Node 18 and python3.11, the issue is the dependency on sharp 0.32.0, which depends on prebuild ^11.0.4 which in turns depends on node-gyp ^6.0.1 which is incompatible with newer versions of python.

Sharp 0.32.6 brings prebuild ^12.0.0 and node-gyp ^9.4.0 solving the issue.

Downgrading to python3.10 (Alpine 3.18 → 3.17) did it for me.

On other environments it might be useful as well to drop down to python3.10.

1 Like

I did try all of these steps on my Mac M1, unfortunately the problem persists both on my project I upgraded and a fresh installation.

Do I need to uninstall node completely from my machine and reinstall?

Same issue here - tried putting it in docker and it worked for a few days but now we have the issue in docker too. Here is the docker file:

FROM node:16-alpine

RUN apk update && apk add --no-cache build-base gcc autoconf automake zlib-dev libpng-dev nasm bash vips-dev

ARG NODE_ENV=development

ENV NODE_ENV=${NODE_ENV}

WORKDIR /opt/

COPY package.json ./

RUN yarn config set network-timeout 600000 -g && yarn install

ENV PATH /opt/node_modules/.bin:$PATH

WORKDIR /opt/app

COPY . .

RUN chown -R node:node /opt/app

USER node

EXPOSE 1337

CMD [“yarn”, “develop”]

And here is the docker-compose.yaml file:

version: ‘3’
services:
strapi:
container_name: strapi
build: ./strapi
image: strapi:latest
restart: unless-stopped
env_file: strapi/.env
volumes:
- ./strapi/config:/opt/app/config
- ./strapi/src:/opt/app/src
- ./strapi/package.json:/opt/package.json
- ./strapi/.env:/opt/app/.env
- ./strapi/public/uploads:/opt/app/public/uploads
ports:
- “1337:1337”

What are we doing wrong?

1 Like

Question what operation system is your PC?

Suddenly I’d started to have same issue as well. Just scaled down the replica set to 0 and later scaled up to 1 and that’s it.

I’d set NODE_TLS_REJECT_UNAUTHORIZED to bypass that. I might expect that something gets borked when I do strapi start

Mac Mini M1

If it broks someting it is image upload that is the only thing sharp is used for.

Ye is an issue with sharp and spesific Macs where under M1’s

Give it a shot starting from node:16-alpine3.17

That didn’t fix it unfortunately :frowning:

Can you try installing sharp with this for me?

Strange. I used your steps and it worked for me on alpine 3.17.

Once you have done apk update && apk add --no-cache build-base gcc autoconf automake zlib-dev libpng-dev nasm bash vips-dev can you type in python3 --version and give the output?

Then when you have done yarn config set network-timeout 600000 -g && yarn install can you go into /opt/app/node_modules/sharp, run yarn install and provide the output?

@ Eventyret I am still getting a dependency timeout error when I attempt to install Strapi. I followed the instructions to install vips and downgrade node and I am still not having any luck.
Environment: Mac OSX Venture, VS Code, Brew/Node
Error:
npx create-strapi-app@latest strapi_cmlcol
? Choose your installation type Quickstart (recommended)
Creating a quickstart project.
Creating a new Strapi application at /Users/Desktop/cml_col/strapi_cmlcol.
Creating files.
Error while installing dependencies:
npm WARN config production Use --omit=dev instead.
npm WARN config optional Use --omit=optional to exclude optional dependencies, or
npm WARN config --include=optional to include them.
npm WARN config
npm WARN config Default value does install optional deps unless otherwise omitted.
npm ERR! code FETCH_ERROR
npm ERR! errno FETCH_ERROR
npm ERR! request to https://codeload.github.com/strapi/ts-zen/tar.gz/66e02232f5997674cc7032ea3ee59d9864863732 failed, reason: undefined

npm ERR! A complete log of this run can be found in: /Users/.npm/_logs/2023-10-02T20_55_42_161Z-debug-0.log
TypeError: Cannot read properties of undefined (reading ‘addBreadcrumb’)
at /Users/.npm/_npx/2d56dd13733e9da7/node_modules/@strapi/generate-new/dist/utils/usage.js:67:28
at Array.forEach ()
at captureStderr (/Users/.npm/_npx/2d56dd13733e9da7/node_modules/@strapi/generate-new/dist/utils/usage.js:66:14)
at createProject (/Users/.npm/_npx/2d56dd13733e9da7/node_modules/@strapi/generate-new/dist/create-project.js:136:41)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async createQuickStartProject (/Users/.npm/_npx/2d56dd13733e9da7/node_modules/@strapi/generate-new/dist/create-quickstart-project.js:21:5)

I just thought I’d mention what worked for me in case it helps anyone else.

In my case I didn’t have a .dockerignore configured correctly to exclude node_modules. This caused the container to try to use binaries that were built for the host platform. This isn’t the way.

I did have a .dockerignore file, but it was one level up in my docker-compose folder. It needed to be in the docker build context… i.e the folder with your Dockerfile in it.

I share my shame so others may learn :joy: