3

I've updated Node and Yarn, but when I'm trying to run yarn install on my NextJS project, it throws this:

...
➤ YN0007: │ sharp@npm:0.29.3 must be built because it never has been before or the last one failed
➤ YN0009: │ sharp@npm:0.29.3 couldn't be built successfully (exit code 1, logs can be found here: D:\TEMP\xfs-6da33975\build.log)
➤ YN0000: └ Completed in 0s 965ms
➤ YN0000: Failed with errors in 1s 538ms

I've got yarn v3.5.0 and Node v20.9.0

Here's a copy of my Package.json for more details

{
  "name": "project",
  "version": "0.1.0",
  "private": true,
  ...
  "dependencies": {
    "@emotion/react": "^11.4.1",
    "@emotion/server": "^11.4.0",
    "@emotion/styled": "^11.3.0",
    "@fontsource/roboto": "^4.5.1",
    "@mui/icons-material": "^5.0.1",
    "@mui/material": "^5.0.2",
    "@mui/styles": "^5.8.4",
    "@stripe/react-stripe-js": "^1.8.1",
    "@stripe/stripe-js": "^1.32.0",
    "@types/echarts": "^4.9.12",
    "@types/lodash.clonedeep": "^4.5.7",
    "@types/react-color": "^3.0.6",
    "echarts": "^5.2.2",
    "echarts-gl": "^2.0.8",
    "env-cmd": "^10.1.0",
    "framer-motion": "^10.15.1",
    "i18next": "^21.2.4",
    "i18next-browser-languagedetector": "^6.1.2",
    "lodash.clonedeep": "^4.5.0",
    "next": "12.1.7-canary.4",
    "next-i18next": "^11.0.0",
    "next-seo": "^4.28.1",
    "next-sitemap": "^3.0.5",
    "react": "^18.2.0",
    "react-calendly": "^4.1.1",
    "react-color": "^2.19.3",
    "react-dom": "^18.2.0",
    "react-i18next": "^11.12.0",
    "react-multi-carousel": "^2.8.0",
    "react-rnd": "^10.3.7",
    "react-use": "^17.4.0",
    "sharp": "^0.29.3"
  },
  "devDependencies": {
    "@types/node": "^17.0.43",
    "@types/react": "17.0.25",
    "babel-runtime": "^6.26.0",
    "eslint": "7.32.0",
    "eslint-config-next": "11.1.2",
    "file-loader": "^6.2.0",
    "typescript": "4.6.2"
  }
}

The bug occurred when I upgraded Node and Yarn to latest versions

7
  • 1
    Can you share a copy of your package.json? Commented Oct 31, 2023 at 14:22
  • stackoverflow.com/questions/54409953/cant-install-sharp I'm seeing a lot of people having difficulty installing sharp. Before you run in the first answer however, it might be a good idea to check out @EdieLemoine's answer as it could be a problem with your Python installation Commented Oct 31, 2023 at 15:22
  • Do i have to install the latest python as well? Even if it is a full NextJS project? Commented Oct 31, 2023 at 15:23
  • potentially - stackoverflow.com/questions/38987430/…. Can you see anything in your error logs? Commented Oct 31, 2023 at 15:25
  • Reinstalling Python helped me getting rid of the first error, but a second one appeared when i tried to launch the dev server Commented Oct 31, 2023 at 15:57

2 Answers 2

3

To those that come across this question and use an M1+ Mac:

My Initial Setup

  • libvips v18.51 (installed with homebrew)
  • node v20.11.0
  • yarn v3.6.4

Error logs

sharp: Detected globally-installed libvips v8.15.1
sharp: Attempting to build from source via node-gyp
sharp: Found node-addon-api
sharp: Found node-gyp version 9.4.0
sharp: See https://sharp.pixelplumbing.com/install#building-from-source
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | arm64
gyp info chdir src
gyp info find Python using Python version 3.11.5 found at "/opt/homebrew/opt/[email protected]/bin/python3.11"
gyp info spawn /opt/homebrew/opt/[email protected]/bin/python3.11
gyp info spawn args [
gyp info spawn args   '/Users/redacted/Documents/dev/joplin/joplin/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/redacted/Documents/dev/joplin/joplin/packages/tools/node_modules/sharp/src/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/redacted/Documents/dev/joplin/joplin/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/redacted/Library/Caches/node-gyp/20.11.0/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/redacted/Library/Caches/node-gyp/20.11.0',
gyp info spawn args   '-Dnode_gyp_dir=/Users/redacted/Documents/dev/joplin/joplin/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/redacted/Library/Caches/node-gyp/20.11.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/redacted/Documents/dev/joplin/joplin/packages/tools/node_modules/sharp/src',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CC(target) Release/obj.target/nothing/../../node-addon-api/nothing.o
  LIBTOOL-STATIC Release/nothing.a
warning: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: archive library: Release/nothing.a the table of contents is empty (no object file members in the library define global symbols)
  TOUCH Release/obj.target/libvips-cpp.stamp
  CXX(target) Release/obj.target/sharp-darwin-arm64/common.o
  CXX(target) Release/obj.target/sharp-darwin-arm64/metadata.o
../metadata.cc:233:46: error: no member named 'NewOrCopy' in 'Napi::Buffer<char>'
        info.Set("exif", Napi::Buffer<char>::NewOrCopy(env, baton->exif, baton->exifLength, sharp::FreeCallback));
                         ~~~~~~~~~~~~~~~~~~~~^
../metadata.cc:236:45: error: no member named 'NewOrCopy' in 'Napi::Buffer<char>'
        info.Set("icc", Napi::Buffer<char>::NewOrCopy(env, baton->icc, baton->iccLength, sharp::FreeCallback));
                        ~~~~~~~~~~~~~~~~~~~~^
../metadata.cc:239:46: error: no member named 'NewOrCopy' in 'Napi::Buffer<char>'
        info.Set("iptc", Napi::Buffer<char>::NewOrCopy(env, baton->iptc, baton->iptcLength, sharp::FreeCallback));
                         ~~~~~~~~~~~~~~~~~~~~^
../metadata.cc:242:45: error: no member named 'NewOrCopy' in 'Napi::Buffer<char>'
        info.Set("xmp", Napi::Buffer<char>::NewOrCopy(env, baton->xmp, baton->xmpLength, sharp::FreeCallback));
                        ~~~~~~~~~~~~~~~~~~~~^
../metadata.cc:246:31: error: no member named 'NewOrCopy' in 'Napi::Buffer<char>'
          Napi::Buffer<char>::NewOrCopy(env, baton->tifftagPhotoshop,
          ~~~~~~~~~~~~~~~~~~~~^
5 errors generated.
make: *** [Release/obj.target/sharp-darwin-arm64/metadata.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/redacted/Documents/dev/joplin/joplin/node_modules/node-gyp/lib/build.js:203:23)
gyp ERR! stack     at ChildProcess.emit (node:events:518:28)
gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:294:12)
gyp ERR! System Darwin 23.3.0
gyp ERR! command "/usr/local/bin/node" "/Users/redacted/Documents/dev/joplin/joplin/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--directory=src"
gyp ERR! cwd /Users/redacted/Documents/dev/joplin/joplin/packages/tools/node_modules/sharp/src
gyp ERR! node -v v20.11.0
gyp ERR! node-gyp -v v9.4.1
gyp ERR! not ok 

What worked for me

  • brew uninstall vips
  • yarn install (yarn.lock can be found here)
Sign up to request clarification or add additional context in comments.

1 Comment

worked for me, thanks!
0

i had the same issue updating your Yarn version to V4.0.1 or down grade your node version to v16.16.0

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.