System Information
Strapi Version :
Operating System :
Database :
Node Version :
NPM Version :
Yarn Version :
Trying to deploy strapi with docker but i’m greeted with this Error:
Cannot find module '../build/Release/sharp-linuxmusl-x64.node'
I’ve Tried the following solutions provided
Possible solutions:
strapi | - Install with verbose logging and look for errors: "npm install --ignore-scripts=false --foreground-scripts --verbose sharp"
strapi | - Install for the current linuxmusl-x64 runtime: "npm install --platform=linuxmusl --arch=x64 sharp"
strapi | - Consult the installation documentation: https://sharp.pixelplumbing.com/install
but it didn’t work,
I’m not sure if I’m doing something wrong
2 Likes
What Dockerfile are you using?
Experienced this same problem. It was because I didn’t have a .dockerignore file in the root directory so the local node_modules folder was getting copied over by docker. It would be helpful if this was mentioned in the Strapi docs for those just getting started with Docker.
Your .dockerignore should contain the following:
.tmp/
.cache/
.git/
build/
node_modules/
.env
data/
If you use @strapi-community /dockerize, it will create this file and your other docker files for you.
7 Likes
mstroiu
February 13, 2023, 2:02pm
5
@goodhoko @thirtyone
I have a similar issue. The build works correctly on local machine via Docker but in the CI(Gitlab), the build breaks.
The logs suggested a missing dependency(sharp
) but after installing it as a dependency, I still get an error.
Please see below the log output.
Removing intermediate container eee59150acf7
---> c6ed1d125f11
Step 3/13 : ARG NODE_ENV=development
---> Running in 9a8e95860629
Removing intermediate container 9a8e95860629
---> 8dcccf7eb9c1
Step 4/13 : ENV NODE_ENV=${NODE_ENV}
---> Running in 64cc964ff052
Removing intermediate container 64cc964ff052
---> 493d47492212
Step 5/13 : WORKDIR /opt/
---> Running in 8557b5ae8845
Removing intermediate container 8557b5ae8845
---> 442403f43d1f
Step 6/13 : COPY ./package.json ./package-lock.json ./
---> 89d9563e36f5
Step 7/13 : ENV PATH /opt/node_modules/.bin:$PATH
---> Running in a5ca79afe808
Removing intermediate container a5ca79afe808
---> 574eed492163
Step 8/13 : RUN npm i
---> Running in 0dfb533949dd
npm info run better-sqlite3@7.4.6 install node_modules/better-sqlite3 prebuild-install || npm run build-release
npm info run sharp@0.31.3 install node_modules/sharp (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
npm info run better-sqlite3@7.4.6 install { code: 0, signal: null }
npm timing build:run:install:node_modules/better-sqlite3 Completed in 1051ms
npm info run sharp@0.31.2 install node_modules/@strapi/plugin-upload/node_modules/sharp (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
npm info run sharp@0.31.3 install { code: 1, signal: null }
npm info run sharp@0.31.2 install { code: 1, signal: null }
npm timing reify:rollback:createSparse Completed in 4431ms
npm timing reify:rollback:retireShallow Completed in 0ms
npm timing command:i Completed in 40259ms
npm notice
npm notice New major version of npm available! 8.19.3 -> 9.4.2
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v9.4.2>
npm notice Run `npm install -g npm@9.4.2` to update!
npm notice
npm verb stack Error: command failed
npm verb stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/lib/index.js:63:27)
npm verb stack at ChildProcess.emit (node:events:513:28)
npm verb stack at maybeClose (node:internal/child_process:1100:16)
npm verb stack at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)
npm verb pkgid sharp@0.31.3
npm verb cwd /opt
npm verb Linux 5.13.0-1022-aws
npm verb node v16.19.0
npm verb npm v8.19.3
npm ERR! code 1
npm ERR! path /opt/node_modules/sharp
npm ERR! command failed
npm ERR! command sh -c -- (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
npm ERR! sharp: Detected globally-installed libvips v8.13.3
npm ERR! sharp: Building from source via node-gyp
I’m not sure what’s failing at the moment. I have my Dockerfile
& .dockerignore
in the root project.
Thank you
1 Like
mstroiu
February 13, 2023, 10:33pm
6
I found the issue.
When the app is starting, do not do anything(register an accout, create content, etc)
After you setup everything in the CI/CD and deploy, then you can create the content.
1 Like
Silon
July 16, 2024, 11:06am
7
Sharp is building during modules installation (yarn install in my case) so release file was created for my local machine which is different than required by this strapi plugin. Fixed by this command:
npm_config_arch=arm64 npm_config_platform=linux npm_config_libc=musl yarn install
These ENV variables are used in: node_modules/sharp/lib/platform.js
1 Like
I am using the strapi community dockerize tool on mac M1. Getting this error while building the image. How to fix it?
1 Like