Npm install --save-dev netlify-cli is not installing with error code 7

I am trying to install netlify-cli per documentation. However, whether I try to install it globally or locally, I get the same error and can’t seem to locate the root of the problem. I am on a Linux system and using VS Code.

1 Like

Your log screenshot provides no useful information. Try checking the debug logs generated by npm or try using a different device. Sounds like something wrong with the current device as the CLI is installing fine on other devices.

Here is some of the log. The log was rather long, so this is only the last part of it.

1927 timing reifyNode:node_modules/netlify-cli/node_modules/@opentelemetry/exporter-trace-otlp-grpc/node_modules/@opentelemetry/sdk-trace-base Completed in 6606ms
1928 timing reifyNode:node_modules/netlify-cli/node_modules/@opentelemetry/sdk-trace-base Completed in 6617ms
1929 timing reifyNode:node_modules/netlify-cli/node_modules/@opentelemetry/resources Completed in 6661ms
1930 timing reifyNode:node_modules/netlify-cli/node_modules/@opentelemetry/exporter-trace-otlp-proto/node_modules/@opentelemetry/resources Completed in 6661ms
1931 timing reifyNode:node_modules/netlify-cli/node_modules/@opentelemetry/sdk-metrics/node_modules/@opentelemetry/resources Completed in 6663ms
1932 timing reifyNode:node_modules/netlify-cli/node_modules/@opentelemetry/exporter-trace-otlp-grpc/node_modules/@opentelemetry/resources Completed in 6660ms
1933 timing reifyNode:node_modules/netlify-cli/node_modules/@opentelemetry/exporter-metrics-otlp-grpc/node_modules/@opentelemetry/resources Completed in 6659ms
1934 timing reifyNode:node_modules/netlify-cli/node_modules/@opentelemetry/sdk-logs/node_modules/@opentelemetry/resources Completed in 6664ms
1935 timing reifyNode:node_modules/netlify-cli/node_modules/@opentelemetry/otlp-transformer/node_modules/@opentelemetry/resources Completed in 6664ms
1936 timing reifyNode:node_modules/netlify-cli/node_modules/@opentelemetry/exporter-metrics-otlp-http/node_modules/@opentelemetry/resources Completed in 6660ms
1937 timing reifyNode:node_modules/netlify-cli/node_modules/fastify Completed in 6763ms
1938 timing reifyNode:node_modules/netlify-cli/node_modules/@netlify/edge-bundler Completed in 6723ms
1939 timing reifyNode:node_modules/netlify-cli/node_modules/web-streams-polyfill Completed in 6890ms
1940 timing reifyNode:node_modules/netlify-cli/node_modules/@opentelemetry/otlp-proto-exporter-base Completed in 6768ms
1941 timing reifyNode:node_modules/netlify-cli/node_modules/@opentelemetry/exporter-trace-otlp-proto/node_modules/@opentelemetry/otlp-proto-exporter-base Completed in 6793ms
1942 timing reifyNode:node_modules/netlify-cli/node_modules/@netlify/edge-bundler/node_modules/@esbuild/linux-x64 Completed in 6856ms
1943 timing reifyNode:node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/node_modules/@esbuild/linux-x64 Completed in 6866ms
1944 timing reifyNode:node_modules/netlify-cli/node_modules/@grpc/grpc-js Completed in 6938ms
1945 timing reifyNode:node_modules/netlify-cli/node_modules/@opentelemetry/api Completed in 6969ms
1946 timing reifyNode:node_modules/netlify-cli/node_modules/fast-json-stringify/node_modules/ajv Completed in 7084ms
1947 timing reifyNode:node_modules/netlify-cli/node_modules/ajv-formats/node_modules/ajv Completed in 7055ms
1948 timing reifyNode:node_modules/netlify-cli/node_modules/@netlify/framework-info/node_modules/ajv Completed in 7026ms
1949 timing reifyNode:node_modules/netlify-cli/node_modules/@netlify/edge-bundler/node_modules/ajv Completed in 7025ms
1950 timing reifyNode:node_modules/netlify-cli/node_modules/@fastify/ajv-compiler/node_modules/ajv Completed in 7014ms
1951 timing reifyNode:node_modules/netlify-cli/node_modules/@opentelemetry/sdk-metrics/node_modules/@opentelemetry/core Completed in 7133ms
1952 timing reifyNode:node_modules/netlify-cli/node_modules/@opentelemetry/core Completed in 7129ms
1953 timing reifyNode:node_modules/netlify-cli/node_modules/@opentelemetry/otlp-exporter-base/node_modules/@opentelemetry/core Completed in 7132ms
1954 timing reifyNode:node_modules/netlify-cli/node_modules/@opentelemetry/sdk-logs/node_modules/@opentelemetry/core Completed in 7136ms
1955 timing reifyNode:node_modules/netlify-cli/node_modules/@opentelemetry/otlp-transformer/node_modules/@opentelemetry/core Completed in 7136ms
1956 timing reifyNode:node_modules/netlify-cli/node_modules/@opentelemetry/otlp-grpc-exporter-base/node_modules/@opentelemetry/core Completed in 7135ms
1957 timing reifyNode:node_modules/netlify-cli/node_modules/@opentelemetry/exporter-trace-otlp-proto/node_modules/@opentelemetry/core Completed in 7135ms
1958 timing reifyNode:node_modules/netlify-cli/node_modules/@opentelemetry/exporter-trace-otlp-grpc/node_modules/@opentelemetry/core Completed in 7134ms
1959 timing reifyNode:node_modules/netlify-cli/node_modules/@netlify/build/node_modules/@opentelemetry/core Completed in 7112ms
1960 timing reifyNode:node_modules/netlify-cli/node_modules/@opentelemetry/exporter-metrics-otlp-http/node_modules/@opentelemetry/core Completed in 7134ms
1961 timing reifyNode:node_modules/netlify-cli/node_modules/@opentelemetry/exporter-metrics-otlp-grpc/node_modules/@opentelemetry/core Completed in 7134ms
1962 timing reifyNode:node_modules/netlify-cli/node_modules/lodash-es Completed in 7221ms
1963 timing reifyNode:node_modules/netlify-cli/node_modules/@opentelemetry/sdk-metrics Completed in 7250ms
1964 timing reifyNode:node_modules/netlify-cli/node_modules/@opentelemetry/sdk-node/node_modules/@opentelemetry/sdk-metrics Completed in 7252ms
1965 timing reifyNode:node_modules/netlify-cli/node_modules/@opentelemetry/exporter-metrics-otlp-proto/node_modules/@opentelemetry/sdk-metrics Completed in 7248ms
1966 timing reifyNode:node_modules/netlify-cli/node_modules/@opentelemetry/exporter-trace-otlp-http/node_modules/@opentelemetry/sdk-metrics Completed in 7250ms
1967 timing reifyNode:node_modules/netlify-cli/node_modules/lodash Completed in 7370ms
1968 timing reifyNode:node_modules/netlify-cli/node_modules/typescript Completed in 7601ms
1969 timing reifyNode:node_modules/netlify-cli/node_modules/rxjs Completed in 7784ms
1970 timing reify:unpack Completed in 7812ms
1971 timing reify:unretire Completed in 0ms
1972 timing build:queue Completed in 24ms
1973 timing build:link:node_modules/ejs Completed in 11ms
1974 timing build:link:node_modules/netlify-cli/node_modules/@babel/parser Completed in 10ms
1975 timing build:link:node_modules/netlify-cli/node_modules/@netlify/edge-bundler/node_modules/@vercel/nft Completed in 7ms
1976 timing build:link:node_modules/netlify-cli/node_modules/@fastify/send/node_modules/mime Completed in 7ms
1977 timing build:link:node_modules/netlify-cli/node_modules/@parcel/watcher/node_modules/detect-libc Completed in 7ms
1978 timing build:link:node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/node_modules/esbuild Completed in 7ms
1979 timing build:link:node_modules/netlify-cli/node_modules/fastify/node_modules/pino Completed in 7ms
1980 timing build:link:node_modules/netlify-cli/node_modules/is-wsl/node_modules/is-docker Completed in 7ms
1981 timing build:link:node_modules/netlify-cli/node_modules/jaeger-client/node_modules/uuid Completed in 7ms
1982 timing build:link:node_modules/netlify-cli/node_modules/make-dir/node_modules/semver Completed in 7ms
1983 timing build:link:node_modules/netlify-cli/node_modules/open/node_modules/is-docker Completed in 7ms
1984 timing build:link:node_modules/netlify-cli/node_modules/require-in-the-middle/node_modules/resolve Completed in 7ms
1985 timing build:link:node_modules/netlify-cli/node_modules/tar/node_modules/mkdirp Completed in 7ms
1986 timing build:link:node_modules/netlify-cli/node_modules/unenv/node_modules/mime Completed in 7ms
1987 timing build:link:node_modules/jake Completed in 10ms
1988 timing build:link:node_modules/mime Completed in 10ms
1989 timing build:link:node_modules/netlify-cli/node_modules/@netlify/local-functions-proxy-linux-x64 Completed in 10ms
1990 timing build:link:node_modules/netlify-cli Completed in 10ms
1991 timing build:link:node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it Completed in 10ms
1992 timing build:link:node_modules/netlify-cli/node_modules/@mapbox/node-pre-gyp Completed in 10ms
1993 timing build:link:node_modules/netlify-cli/node_modules/@grpc/proto-loader Completed in 10ms
1994 timing build:link:node_modules/netlify-cli/node_modules/@netlify/build-info Completed in 10ms
1995 timing build:link:node_modules/netlify-cli/node_modules/@vercel/nft Completed in 10ms
1996 timing build:link:node_modules/netlify-cli/node_modules/@netlify/build Completed in 10ms
1997 timing build:link:node_modules/netlify-cli/node_modules/ansi-to-html Completed in 9ms
1998 timing build:link:node_modules/netlify-cli/node_modules/atob Completed in 9ms
1999 timing build:link:node_modules/netlify-cli/node_modules/color-support Completed in 9ms
2000 timing build:link:node_modules/netlify-cli/node_modules/crc-32 Completed in 9ms
2001 timing build:link:node_modules/netlify-cli/node_modules/detective-amd Completed in 9ms
2002 timing build:link:node_modules/netlify-cli/node_modules/acorn Completed in 9ms
2003 timing build:link:node_modules/netlify-cli/node_modules/envinfo Completed in 9ms
2004 timing build:link:node_modules/netlify-cli/node_modules/escodegen Completed in 10ms
2005 timing build:link:node_modules/netlify-cli/node_modules/esprima Completed in 10ms
2006 timing build:link:node_modules/netlify-cli/node_modules/extract-zip Completed in 10ms
2007 timing build:link:node_modules/netlify-cli/node_modules/gonzales-pe Completed in 10ms
2008 timing build:link:node_modules/netlify-cli/node_modules/hexer Completed in 10ms
2009 timing build:link:node_modules/netlify-cli/node_modules/ipx Completed in 10ms
2010 timing build:link:node_modules/netlify-cli/node_modules/is-ci Completed in 10ms
2011 timing build:link:node_modules/netlify-cli/node_modules/is-docker Completed in 10ms
2012 timing build:link:node_modules/netlify-cli/node_modules/jiti Completed in 10ms
2013 timing build:link:node_modules/netlify-cli/node_modules/js-yaml Completed in 10ms
2014 timing build:link:node_modules/netlify-cli/node_modules/lambda-local Completed in 10ms
2015 timing build:link:node_modules/netlify-cli/node_modules/listhen Completed in 10ms
2016 timing build:link:node_modules/netlify-cli/node_modules/mime Completed in 9ms
2017 timing build:link:node_modules/netlify-cli/node_modules/mkdirp Completed in 9ms
2018 timing build:link:node_modules/netlify-cli/node_modules/nanoid Completed in 9ms
2019 timing build:link:node_modules/netlify-cli/node_modules/module-definition Completed in 9ms
2020 timing build:link:node_modules/netlify-cli/node_modules/@netlify/config Completed in 11ms
2021 timing build:link:node_modules/netlify-cli/node_modules/node-gyp-build Completed in 9ms
2022 timing build:link:node_modules/netlify-cli/node_modules/nopt Completed in 9ms
2023 timing build:link:node_modules/netlify-cli/node_modules/parse-github-url Completed in 9ms
2024 timing build:link:node_modules/netlify-cli/node_modules/precinct Completed in 9ms
2025 timing build:link:node_modules/netlify-cli/node_modules/prettyjson Completed in 9ms
2026 timing build:link:node_modules/netlify-cli/node_modules/prebuild-install Completed in 9ms
2027 timing build:link:node_modules/netlify-cli/node_modules/rc Completed in 9ms
2028 timing build:link:node_modules/netlify-cli/node_modules/resolve Completed in 9ms
2029 timing build:link:node_modules/netlify-cli/node_modules/rimraf Completed in 9ms
2030 timing build:link:node_modules/netlify-cli/node_modules/seek-bzip Completed in 9ms
2031 timing build:link:node_modules/netlify-cli/node_modules/semver Completed in 9ms
2032 timing build:link:node_modules/netlify-cli/node_modules/svgo Completed in 9ms
2033 timing build:link:node_modules/netlify-cli/node_modules/thriftrw Completed in 9ms
2034 timing build:link:node_modules/netlify-cli/node_modules/xss Completed in 8ms
2035 timing build:link:node_modules/netlify-cli/node_modules/ts-node Completed in 9ms
2036 timing build:link:node_modules/netlify-cli/node_modules/typescript Completed in 8ms
2037 timing build:link:node_modules/netlify-cli/node_modules/regexp-tree Completed in 9ms
2038 timing build:link:node_modules/netlify-cli/node_modules/ulid Completed in 8ms
2039 timing build:link:node_modules/netlify-cli/node_modules/untun Completed in 8ms
2040 timing build:link:node_modules/netlify-cli/node_modules/uuid Completed in 8ms
2041 timing build:link:node_modules/netlify-cli/node_modules/wait-port Completed in 8ms
2042 timing build:link:node_modules/netlify-cli/node_modules/which Completed in 9ms
2043 timing build:link:node_modules/netlify-cli/node_modules/@netlify/edge-bundler/node_modules/esbuild Completed in 9ms
2044 timing build:link Completed in 13ms
2045 info run sharp@0.32.6 install node_modules/netlify-cli/node_modules/sharp (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
2046 info run unix-dgram@2.0.6 install node_modules/netlify-cli/node_modules/unix-dgram node-gyp rebuild
2047 info run unix-dgram@2.0.6 install { code: 7, signal: null }
2048 verbose reify failed optional dependency /home/jim/Desktop/Learn Programming/Web Dev Learning/BackEnd/5.3 Axios/node_modules/netlify-cli/node_modules/unix-dgram
2049 silly reify mark deleted [
2049 silly reify   '/home/jim/Desktop/Learn Programming/Web Dev Learning/BackEnd/5.3 Axios/node_modules/netlify-cli/node_modules/unix-dgram'
2049 silly reify ]
2050 verbose reify failed optional dependency /home/jim/Desktop/Learn Programming/Web Dev Learning/BackEnd/5.3 Axios/node_modules/netlify-cli/node_modules/nan
2051 silly reify mark deleted [
2051 silly reify   '/home/jim/Desktop/Learn Programming/Web Dev Learning/BackEnd/5.3 Axios/node_modules/netlify-cli/node_modules/nan'
2051 silly reify ]
2052 timing build:run:install:node_modules/netlify-cli/node_modules/unix-dgram Completed in 116ms
2053 info run sharp@0.32.6 install { code: 7, signal: null }
2054 timing reify:rollback:createSparse Completed in 2123ms
2055 timing reify:rollback:retireShallow Completed in 0ms
2056 timing command:install Completed in 11726ms
2057 verbose stack Error: command failed
2057 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/lib/index.js:53:27)
2057 verbose stack     at ChildProcess.emit (node:events:517:28)
2057 verbose stack     at maybeClose (node:internal/child_process:1098:16)
2057 verbose stack     at ChildProcess._handle.onexit (node:internal/child_process:303:5)
2058 verbose pkgid sharp@0.32.6
2059 verbose cwd /home/jim/Desktop/Learn Programming/Web Dev Learning/BackEnd/5.3 Axios
2060 verbose Linux 5.15.0-89-generic
2061 verbose node v18.18.0
2062 verbose npm  v10.2.5
2063 error code 7
2064 error path /home/jim/Desktop/Learn Programming/Web Dev Learning/BackEnd/5.3 Axios/node_modules/netlify-cli/node_modules/sharp
2065 error command failed
2066 error command sh -c (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
2067 verbose exit 7
2068 timing npm Completed in 11906ms
2069 verbose unfinished npm timer reify 1702902351122
2070 verbose unfinished npm timer reify:build 1702902360132
2071 verbose unfinished npm timer build 1702902360135
2072 verbose unfinished npm timer build:deps 1702902360136
2073 verbose unfinished npm timer build:run:install 1702902360173
2074 verbose unfinished npm timer build:run:install:node_modules/netlify-cli/node_modules/sharp 1702902360173
2075 verbose code 7
2076 error A complete log of this run can be found in: /home/jim/.npm/_logs/2023-12-18T12_25_50_944Z-debug-0.log

Based on this, the install command seems to be successful, but looks like something went wrong with npm itself.

I’m seeing the same error when trying to update to the latest release via npm update -g netlify-cli:

npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
npm ERR! code 7
npm ERR! path /home/salim/.software/managed/npm/lib/node_modules/netlify-cli/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! A complete log of this run can be found in: /home/salim/.cache/npm/_logs/2024-01-11T18_18_48_149Z-debug-0.log

Relevant lines from the installation log:

1720 timing build:link:node_modules/netlify-cli/node_modules/listhen Completed in 11ms
1721 timing build:link:node_modules/netlify-cli/node_modules/mkdirp Completed in 11ms
1722 timing build:link:node_modules/netlify-cli/node_modules/parse-github-url Completed in 11ms
1723 timing build:link:node_modules/netlify-cli/node_modules/prebuild-install Completed in 11ms
1724 timing build:link Completed in 14ms
1725 info run sharp@0.32.6 install node_modules/netlify-cli/node_modules/sharp (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
1726 info run unix-dgram@2.0.6 install node_modules/netlify-cli/node_modules/unix-dgram node-gyp rebuild
1727 info run unix-dgram@2.0.6 install { code: 7, signal: null }
1728 verbose reify failed optional dependency /home/salim/.software/managed/npm/lib/node_modules/netlify-cli/node_modules/unix-dgram
1729 silly reify mark deleted [
1729 silly reify   '/home/salim/.software/managed/npm/lib/node_modules/netlify-cli/node_modules/unix-dgram'
1729 silly reify ]
1730 verbose reify failed optional dependency /home/salim/.software/managed/npm/lib/node_modules/netlify-cli/node_modules/nan
1731 silly reify mark deleted [
1731 silly reify   '/home/salim/.software/managed/npm/lib/node_modules/netlify-cli/node_modules/nan'
1731 silly reify ]
1732 timing build:run:install:node_modules/netlify-cli/node_modules/unix-dgram Completed in 139ms
1733 info run sharp@0.32.6 install { code: 7, signal: null }
1734 timing reify:rollback:createSparse Completed in 1003ms
1735 timing reify:rollback:retireShallow Completed in 0ms
1736 timing command:update Completed in 12131ms
1737 verbose stack Error: command failed
1737 verbose stack     at ChildProcess.<anonymous> (/snap/node/8169/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/lib/index.js:53:27)
1737 verbose stack     at ChildProcess.emit (node:events:518:28)
1737 verbose stack     at maybeClose (node:internal/child_process:1105:16)
1737 verbose stack     at ChildProcess._handle.onexit (node:internal/child_process:305:5)
1738 verbose pkgid sharp@0.32.6
1739 verbose cwd /home/salim
1740 verbose Linux 6.5.0-14-generic
1741 verbose node v20.11.0
1742 verbose npm  v10.2.4
1743 error code 7
1744 error path /home/salim/.software/managed/npm/lib/node_modules/netlify-cli/node_modules/sharp
1745 error command failed
1746 error command sh -c (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
1747 verbose exit 7
1748 timing npm Completed in 12391ms
1749 verbose unfinished npm timer reify 1704997128468
1750 verbose unfinished npm timer reify:build 1704997138956
1751 verbose unfinished npm timer build 1704997138959
1752 verbose unfinished npm timer build:deps 1704997138959
1753 verbose unfinished npm timer build:run:install 1704997139003
1754 verbose unfinished npm timer build:run:install:node_modules/netlify-cli/node_modules/sharp 1704997139004
1755 verbose code 7
1756 error A complete log of this run can be found in: /home/salim/.cache/npm/_logs/2024-01-11T18_18_48_149Z-debug-0.log

netlify-cli is the first npm package causing the above error for me. Other npm packages install fine.

I can reproduce this on both my Ubuntu 22.04 machines, one with an Intel CPU, the other with an AMD CPU if that matters.

npm version gives:


  npm: '10.2.4',
  node: '20.11.0',
  acorn: '8.11.2',
  ada: '2.7.4',
  ares: '1.20.1',
  base64: '0.5.1',
  brotli: '1.0.9',
  cjs_module_lexer: '1.2.2',
  cldr: '43.1',
  icu: '73.2',
  llhttp: '8.1.1',
  modules: '115',
  napi: '9',
  nghttp2: '1.58.0',
  nghttp3: '0.7.0',
  ngtcp2: '0.8.1',
  openssl: '3.0.12+quic',
  simdutf: '4.0.4',
  tz: '2023c',
  undici: '5.27.2',
  unicode: '15.0',
  uv: '1.46.0',
  uvwasi: '0.0.19',
  v8: '11.3.244.8-node.17',
  zlib: '1.2.13.1-motley-5daffc7'
}

I dug a bit further and apparently the culprit is the sharp module in version 0.32.6.

npm rebuild -g --verbose sharp outputs:

npm verb cli /snap/node/8169/bin/node /snap/node/8169/bin/npm
npm info using npm@10.2.4
npm info using node@v20.11.0
npm verb title npm rebuild sharp
npm verb argv "rebuild" "--global" "--loglevel" "verbose" "sharp"
npm verb logfile logs-max:10 dir:/home/salim/.cache/npm/_logs/2024-01-11T19_03_02_736Z-
npm verb logfile /home/salim/.cache/npm/_logs/2024-01-11T19_03_02_736Z-debug-0.log
npm info run sharp@0.32.6 install node_modules/netlify-cli/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.32.6 install { code: 7, signal: null }
npm verb stack Error: command failed
npm verb stack     at ChildProcess.<anonymous> (/snap/node/8169/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/lib/index.js:53:27)
npm verb stack     at ChildProcess.emit (node:events:518:28)
npm verb stack     at maybeClose (node:internal/child_process:1105:16)
npm verb stack     at ChildProcess._handle.onexit (node:internal/child_process:305:5)
npm verb pkgid sharp@0.32.6
npm verb cwd /home/salim/Downloads
npm verb Linux 6.5.0-14-generic
npm verb node v20.11.0
npm verb npm  v10.2.4
npm ERR! code 7
npm ERR! path /home/salim/.software/managed/npm/lib/node_modules/netlify-cli/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 verb exit 7
npm verb unfinished npm timer build 1704999783681
npm verb unfinished npm timer build:deps 1704999783682
npm verb unfinished npm timer build:run:install 1704999783682
npm verb unfinished npm timer build:run:install:node_modules/netlify-cli/node_modules/sharp 1704999783683
npm verb code 7

The same error is thrown when trying to npm install -g sharp@0.32.6.

The latest version 0.33.1 OTOH installs fine, so the underlying problem seems to already been fixed upstream. But netlify-cli currently uses 0.32.6. Updating that package should solve the issue.

Addendum: The issue only occurs with Node.js/npm installed via Snap. With Node.js/npm installed via fnm, all is fine.