Problem deploying with astro 4

Hi guys,

I’m having deployment problems at build time with my website which is running latest version of Astro framework (version 4.0.8).

It gives me a strange error of not founding sharp library which is installed.

If a newbie using node and astro, so if a more experienced dev could help I would be appreciated.

1:46:57 AM: build-image version: c88e1420630449f4a2fd995ed7cd2ef80eeab5f6 (focal)
1:46:57 AM: buildbot version: c88e1420630449f4a2fd995ed7cd2ef80eeab5f6
1:46:57 AM: Fetching cached dependencies
1:46:57 AM: Failed to fetch cache, continuing with build
1:46:57 AM: Starting to prepare the repo for build
1:46:57 AM: No cached dependencies found. Cloning fresh repo
1:46:57 AM: git clone --filter=blob:none https://github.com/BrunoMiguelMonteiro/workingbruno_v6
1:46:57 AM: Preparing Git Reference refs/heads/main
1:46:59 AM: Starting to install dependencies
1:46:59 AM: Python version set to 3.8
1:46:59 AM: Attempting Ruby version 2.7.2, read from environment
1:47:00 AM: Using Ruby version 2.7.2
1:47:00 AM: Started restoring cached go cache
1:47:00 AM: Finished restoring cached go cache
1:47:02 AM: go version go1.19.13 linux/amd64
1:47:02 AM: Using PHP version 8.0
1:47:03 AM: v18.19.0 is already installed.
1:47:03 AM: Now using node v18.19.0 (npm v10.2.3)
1:47:03 AM: Enabling Node.js Corepack
1:47:03 AM: Started restoring cached build plugins
1:47:03 AM: Finished restoring cached build plugins
1:47:03 AM: Started restoring cached corepack dependencies
1:47:03 AM: Finished restoring cached corepack dependencies
1:47:03 AM: Started restoring cached yarn cache
1:47:03 AM: Finished restoring cached yarn cache
1:47:04 AM: No yarn workspaces detected
1:47:04 AM: Started restoring cached node modules
1:47:04 AM: Finished restoring cached node modules
1:47:04 AM: Installing npm packages using Yarn version 1.22.19
1:47:04 AM: yarn install v1.22.19
1:47:04 AM: warning package.json: No license field
1:47:04 AM: warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
1:47:04 AM: warning workingbruno_v6@0.0.1: No license field
1:47:04 AM: [1/4] Resolving packages...
1:47:07 AM: [2/4] Fetching packages...
1:47:14 AM: warning sharp@0.33.1: The engine "libvips" appears to be invalid.
1:47:14 AM: warning @img/sharp-darwin-arm64@0.33.1: The engine "pnpm" appears to be invalid.
1:47:14 AM: warning @img/sharp-darwin-arm64@0.33.1: The engine "glibc" appears to be invalid.
1:47:14 AM: warning @img/sharp-libvips-darwin-arm64@1.0.0: The engine "pnpm" appears to be invalid.
1:47:14 AM: warning @img/sharp-libvips-darwin-arm64@1.0.0: The engine "macos" appears to be invalid.
1:47:14 AM: warning @img/sharp-libvips-linux-arm64@1.0.0: The engine "pnpm" appears to be invalid.
1:47:14 AM: warning @img/sharp-libvips-linux-arm64@1.0.0: The engine "glibc" appears to be invalid.
1:47:14 AM: warning @img/sharp-libvips-darwin-x64@1.0.0: The engine "pnpm" appears to be invalid.
1:47:14 AM: warning @img/sharp-libvips-darwin-x64@1.0.0: The engine "macos" appears to be invalid.
1:47:14 AM: warning @img/sharp-libvips-linux-s390x@1.0.0: The engine "pnpm" appears to be invalid.
1:47:14 AM: warning @img/sharp-libvips-linux-s390x@1.0.0: The engine "glibc" appears to be invalid.
1:47:14 AM: warning @img/sharp-linux-s390x@0.33.1: The engine "pnpm" appears to be invalid.
1:47:14 AM: warning @img/sharp-linux-s390x@0.33.1: The engine "glibc" appears to be invalid.
1:47:14 AM: warning @img/sharp-linux-x64@0.33.1: The engine "pnpm" appears to be invalid.
1:47:14 AM: warning @img/sharp-linux-x64@0.33.1: The engine "glibc" appears to be invalid.
1:47:14 AM: warning @img/sharp-darwin-x64@0.33.1: The engine "pnpm" appears to be invalid.
1:47:14 AM: warning @img/sharp-darwin-x64@0.33.1: The engine "glibc" appears to be invalid.
1:47:14 AM: warning @img/sharp-libvips-linuxmusl-arm64@1.0.0: The engine "pnpm" appears to be invalid.
1:47:14 AM: warning @img/sharp-libvips-linuxmusl-arm64@1.0.0: The engine "musl" appears to be invalid.
1:47:14 AM: warning @img/sharp-libvips-linuxmusl-x64@1.0.0: The engine "pnpm" appears to be invalid.
1:47:14 AM: warning @img/sharp-libvips-linuxmusl-x64@1.0.0: The engine "musl" appears to be invalid.
1:47:14 AM: warning @img/sharp-win32-ia32@0.33.1: The engine "pnpm" appears to be invalid.
1:47:14 AM: warning @img/sharp-linux-arm64@0.33.1: The engine "pnpm" appears to be invalid.
1:47:14 AM: warning @img/sharp-linux-arm64@0.33.1: The engine "glibc" appears to be invalid.
1:47:14 AM: warning @img/sharp-libvips-linux-arm@1.0.0: The engine "pnpm" appears to be invalid.
1:47:14 AM: warning @img/sharp-libvips-linux-arm@1.0.0: The engine "glibc" appears to be invalid.
1:47:14 AM: warning @img/sharp-libvips-linux-x64@1.0.0: The engine "pnpm" appears to be invalid.
1:47:14 AM: warning @img/sharp-libvips-linux-x64@1.0.0: The engine "glibc" appears to be invalid.
1:47:14 AM: warning @img/sharp-win32-x64@0.33.1: The engine "pnpm" appears to be invalid.
1:47:14 AM: warning @img/sharp-linux-arm@0.33.1: The engine "pnpm" appears to be invalid.
1:47:14 AM: warning @img/sharp-linux-arm@0.33.1: The engine "glibc" appears to be invalid.
1:47:14 AM: warning @img/sharp-wasm32@0.33.1: The engine "pnpm" appears to be invalid.
1:47:14 AM: warning @img/sharp-linuxmusl-x64@0.33.1: The engine "pnpm" appears to be invalid.
1:47:14 AM: warning @img/sharp-linuxmusl-x64@0.33.1: The engine "musl" appears to be invalid.
1:47:14 AM: warning @img/sharp-linuxmusl-arm64@0.33.1: The engine "pnpm" appears to be invalid.
1:47:14 AM: warning @img/sharp-linuxmusl-arm64@0.33.1: The engine "musl" appears to be invalid.
1:47:14 AM: [3/4] Linking dependencies...
1:47:14 AM: warning "@astrojs/react > @vitejs/plugin-react@4.2.1" has unmet peer dependency "vite@^4.2.0 || ^5.0.0".
1:47:14 AM: warning Workspaces can only be enabled in private projects.
1:47:15 AM: [4/4] Building fresh packages...
1:47:16 AM: success Saved lockfile.
1:47:16 AM: Done in 12.01s.
1:47:16 AM: npm packages installed using Yarn
1:47:17 AM: Successfully installed dependencies
1:47:17 AM: Starting build script
1:47:18 AM: Detected 1 framework(s)
1:47:18 AM: "astro" at version "4.0.8"
1:47:18 AM: Section completed: initializing
1:47:19 AM: ​
1:47:19 AM: Netlify Build                                                 
1:47:19 AM: ────────────────────────────────────────────────────────────────
1:47:19 AM: ​
1:47:19 AM: ❯ Version
1:47:19 AM:   @netlify/build 29.31.1
1:47:19 AM: ​
1:47:19 AM: ❯ Flags
1:47:19 AM:   baseRelDir: true
1:47:19 AM:   buildId: 65936b039dc1eb000858b589
1:47:19 AM:   deployId: 65936b039dc1eb000858b58b
1:47:19 AM: ​
1:47:19 AM: ❯ Current directory
1:47:19 AM:   /opt/build/repo
1:47:19 AM: ​
1:47:19 AM: ❯ Config file
1:47:19 AM:   No config file was defined: using default values.
1:47:19 AM: ​
1:47:19 AM: ❯ Context
1:47:19 AM:   production
1:47:19 AM: ​
1:47:19 AM: ❯ Installing plugins
1:47:19 AM:    - @netlify/plugin-lighthouse@5.0.0
1:47:31 AM: ​
1:47:31 AM: ❯ Loading plugins
1:47:31 AM:    - @netlify/plugin-lighthouse@5.0.0 from Netlify app
1:47:32 AM: ​
1:47:32 AM: Build command from Netlify app                                
1:47:32 AM: ────────────────────────────────────────────────────────────────
1:47:32 AM: ​
1:47:32 AM: $ npm run build
1:47:33 AM: > workingbruno_v6@0.0.1 build
1:47:33 AM: > astro build
1:47:34 AM: 01:47:34 Types generated 265ms
1:47:34 AM: 01:47:34 [build] output: "static"
1:47:34 AM: 01:47:34 [build] directory: /opt/build/repo/dist/
1:47:34 AM: 01:47:34 [build] Collecting build info...
1:47:34 AM: 01:47:34 [build] βœ“ Completed in 281ms.
1:47:34 AM: 01:47:34 [build] Building static entrypoints...
1:47:36 AM: 01:47:36 [WARN] [vite] warnings when minifying css:
1:47:36 AM: β–² [WARNING] Expected identifier but found "(" [css-syntax-error]
1:47:36 AM:     <stdin>:1:23:
1:47:36 AM:       1 β”‚ .article__content > is:(h3){color:var(--c-primary);font-size:1.8rem...
1:47:36 AM:         β•΅                        ^
1:47:36 AM: 
1:47:36 AM: 01:47:36 [WARN] [vite] warnings when minifying css:
1:47:36 AM: β–² [WARNING] Unexpected "}" [css-syntax-error]
1:47:36 AM:     <stdin>:1:0:
1:47:36 AM:       1 β”‚ } */{}.note[data-astro-cid-s5wqhb2v]{border-bottom:1px solid var(--...
1:47:36 AM:         β•΅ ^
1:47:36 AM: 
1:47:36 AM: 01:47:36 [build] βœ“ Completed in 2.00s.
1:47:36 AM:  building client (vite) 
1:47:36 AM: 01:47:36 [vite] transforming...
1:47:36 AM: 01:47:36 [vite] βœ“ 14 modules transformed.
1:47:36 AM: Generated an empty chunk: "hoisted".
1:47:36 AM: 01:47:36 [vite] rendering chunks...
1:47:36 AM: 01:47:36 [vite] computing gzip size...
1:47:36 AM: 01:47:36 [vite] dist/_astro/YouTube.astro_astro_type_script_index_0_lang.2dKhetbE.js   1.70 kB β”‚ gzip: 0.80 kB
1:47:36 AM: 01:47:36 [vite] dist/_astro/hoisted.4PK_pqbL.js                                       12.03 kB β”‚ gzip: 4.26 kB
1:47:36 AM: 01:47:36 [vite] βœ“ built in 106ms
1:47:36 AM:  generating static routes 
1:47:36 AM: 01:47:36 β–Ά src/pages/index.astro
1:47:36 AM: 01:47:36   └─ /index.html (+19ms)
1:47:36 AM: 01:47:36 β–Ά src/pages/reading.astro
1:47:36 AM: 01:47:36   └─ /reading/index.html (+7ms)
1:47:36 AM: 01:47:36 Ξ» src/pages/rss.xml.ts
1:47:36 AM: 01:47:36   └─ /rss.xml01:47:36 [WARN] [router] No API Route handler exists for the method "GET" for the route /rss.xml.
1:47:36 AM: Found handlers: "get"
1:47:36 AM:  (+1ms)
1:47:36 AM: 01:47:36 β–Ά src/pages/about.astro
1:47:36 AM: 01:47:36   └─ /about/index.html (+3ms)
1:47:36 AM: 01:47:36 β–Ά src/pages/login.astro
1:47:36 AM: 01:47:36   └─ /login/index.html (+2ms)
1:47:36 AM: 01:47:36 β–Ά src/pages/notes/[...slug].astro
1:47:36 AM: 01:47:36   β”œβ”€ /notes/2023-11-05-weekly3/index.html (+4ms)
1:47:36 AM: 01:47:36   β”œβ”€ /notes/2023-11-11-open-planet-is-a-much-need-project/index.html (+4ms)
1:47:36 AM: 01:47:36   β”œβ”€ /notes/coming-soon-planet-earth/index.html (+6ms)
1:47:36 AM: 01:47:36   β”œβ”€ /notes/a-mac-darkmatter-for-your-astro/index.html (+6ms)
1:47:36 AM: 01:47:36   β”œβ”€ /notes/great-books-explained/index.html (+4ms)
1:47:36 AM: 01:47:36   β”œβ”€ /notes/intentions-and-aspirations-for-2024/index.html (+4ms)
1:47:36 AM: 01:47:36   β”œβ”€ /notes/markdown-style-guide/index.html (+4ms)
1:47:36 AM: 01:47:36   β”œβ”€ /notes/personal-website-as-digital-garden/index.html (+6ms)
1:47:36 AM: 01:47:36   β”œβ”€ /notes/the-weekly-1/index.html (+3ms)
1:47:36 AM: 01:47:36   β”œβ”€ /notes/using-mdx/index.html (+4ms)
1:47:36 AM: 01:47:36   └─ /notes/weekly-2/index.html (+3ms)
1:47:36 AM: 01:47:36 β–Ά src/pages/notes/[...page].astro
1:47:36 AM: 01:47:36   └─ /notes/index.html (+3ms)
1:47:36 AM: 01:47:36 β–Ά src/pages/work/index.astro
1:47:36 AM: 01:47:36   └─ /work/index.html (+4ms)
1:47:36 AM: 01:47:36 β–Ά src/pages/work/[...slug].astro
1:47:36 AM: 01:47:36   β”œβ”€ /work/acredita/index.html (+4ms)
1:47:36 AM: 01:47:36   β”œβ”€ /work/myfct/index.html (+5ms)
1:47:36 AM: 01:47:36   β”œβ”€ /work/qda/index.html (+6ms)
1:47:36 AM: 01:47:36   └─ /work/cienciaid/index.html (+6ms)
1:47:36 AM: 01:47:36 βœ“ Completed in 169ms.
1:47:36 AM: 
1:47:36 AM:  generating optimized images 
1:47:36 AM: [CouldNotTransformImage] Could not transform image `/_astro/thumb_acredita.uOSHTNFo.jpg`. See the stack trace for more information.
1:47:36 AM:   Hint:
1:47:36 AM:     This is often caused by a corrupted or malformed image. Re-exporting the image from your image editor may fix this issue.
1:47:36 AM:   Error reference:
1:47:36 AM:     https://docs.astro.build/en/reference/errors/could-not-transform-image/
1:47:36 AM:   Stack trace:
1:47:36 AM:     at generateImageInternal (file:///opt/build/repo/node_modules/astro/dist/assets/build/generate.js:129:21)
1:47:36 AM:     at async file:///opt/build/repo/node_modules/p-queue/dist/index.js:187:36
1:47:36 AM:   Caused by:
1:47:36 AM:   Could not find Sharp. Please install Sharp (`sharp`) manually into your project or migrate to another image service.
1:47:36 AM:     at loadSharp (file:///opt/build/repo/dist/chunks/astro/assets-service_o86j8oIe.mjs:289:11)
1:47:36 AM:     at async generateImageInternal (file:///opt/build/repo/node_modules/astro/dist/assets/build/generate.js:123:26)
1:47:36 AM:     at async file:///opt/build/repo/node_modules/p-queue/dist/index.js:187:36
1:47:36 AM: ​
1:47:36 AM: "build.command" failed                                        
1:47:36 AM: ────────────────────────────────────────────────────────────────
1:47:36 AM: ​
1:47:36 AM:   Error message
1:47:36 AM:   Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
1:47:36 AM: ​
1:47:36 AM:   Error location
1:47:36 AM:   In Build command from Netlify app:
1:47:36 AM:   npm run build
1:47:36 AM: ​
1:47:36 AM:   Resolved config
1:47:36 AM:   build:
1:47:36 AM:     command: npm run build
1:47:36 AM:     commandOrigin: ui
1:47:36 AM:     publish: /opt/build/repo/dist
1:47:36 AM:     publishOrigin: ui
1:47:36 AM:   plugins:
1:47:36 AM:     - inputs: {}
1:47:36 AM:       origin: ui
1:47:36 AM:       package: "@netlify/plugin-lighthouse"
1:47:37 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
1:47:37 AM: Failing build: Failed to build site
1:47:37 AM: Finished processing build request in 40.534s
1:47:37 AM: Failed during stage "building site": Build script returned non-zero exit code: 2

Than you in advance.
A great year for all!

Best regards,
B.

1 Like

Hey Bruno,

Thanks for reaching out! Can you post a snippet of your package.json file when you get a chance? Per the Astro docs, sharp should be used by default when you use Astro’s Image component unless you’re using a strict package manager like pnpm, in which case it needs to be manually installed.

Since you mentioned that sharp is indeed installed on the project, a snippet of the package.json file should help us narrow down what’s going on here. It also may be a good idea to (if you haven’t already) try a deploy with no cache or recreate your package-lock.json file and push that up to ensure there are no mismatches there as well. Looking forward to hearing from you and getting this sorted!

1 Like

Hi Marcus,

Thanks for the quick reply.
I’m a designer, so I’m a little out of my knowledge area :grin:

I used the npm install --package-lock-only for recreating the package-lock.json but it recreated the yarn.lock file (it’s possible that I’ve used yarn for installing a package…but lately I’ve been using npm) and tried to redeploy using the empty cache option with no success.

Here’s the package.json content:

`{
  "name": "workingbruno_v6",
  "type": "module",
  "version": "0.0.1",
  "scripts": {
    "dev": "astro dev",
    "start": "astro dev",
    "build": "astro build",
    "preview": "astro preview",
    "astro": "astro"
  },
  "dependencies": {
    "@astro-community/astro-embed-youtube": "^0.4.3",
    "@astrojs/check": "^0.3.4",
    "@astrojs/mdx": "^2.0.3",
    "@astrojs/netlify": "^4.0.2",
    "@astrojs/partytown": "^2.0.3",
    "@astrojs/react": "^3.0.9",
    "@astrojs/rss": "^4.0.1",
    "@astrojs/sitemap": "^3.0.4",
    "@types/react": "^18.2.28",
    "@types/react-dom": "^18.2.13",
    "astro": "^4.0.8",
    "astro-google-analytics": "^1.0.3",
    "markdown-it": "^13.0.2",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "sanitize-html": "^2.11.0",
    "sharp": "^0.33.1",
    "typescript": "^5.2.2"
  }
}
`

Thanks a lot for your help, Marcus.

No worries! I took a quick look back at your site, and it looks like the most recent deploys have been successful :tada: Please let us know if you’ve resolved the issue, and consider posting the solution for anyone else who might hit this as well. Thanks again!

Hey Marcus,

I think the @astrojs/netlify: ^4.1.0 update with astro 4.0.9 solved the problem with sharp library.
But a workaround could be just using another image service on the astro.config.mjs:

  image: {
     service: {
       entrypoint: 'astro/assets/services/noop'
    }

Thanks for your support.

Best,
B.

Hiya, glad you found your solution. Thanks for writing back in and sharing this with the community.