Build Error - Dependencies installation error - Could not resolve "@astrojs/netlify/netlify-functions.js"

Hey guys, I’ve got an astro build, which is deployed successfully and it seems as though the builds are succeeding, but when I go into my ‘deploys’ tab, it says they have failed with the error message:

1:55:22 PM: Build ready to start
1:55:24 PM: build-image version: 8b79b5e0c585f1b3f892b8032389b4b4b188d887 (focal)
1:55:24 PM: build-image tag: v4.14.0
1:55:24 PM: buildbot version: 1e88a9b854b49555d21dc539e2b8bf5fb78a8f57
1:55:24 PM: Fetching cached dependencies
1:55:24 PM: Starting to download cache of 437.7MB
1:55:28 PM: Finished downloading cache in 4.11806335s
1:55:28 PM: Starting to extract cache
1:55:30 PM: Finished extracting cache in 1.910661982s
1:55:30 PM: Finished fetching cache in 6.100647393s
1:55:30 PM: Starting to prepare the repo for build
1:55:30 PM: Preparing Git Reference refs/heads/master
1:55:30 PM: Parsing package.json dependencies
1:55:31 PM: Starting build script
1:55:31 PM: Installing dependencies
1:55:31 PM: Python version set to 2.7
1:55:32 PM: Started restoring cached node version
1:55:33 PM: Finished restoring cached node version
1:55:33 PM: v16.18.0 is already installed.
1:55:33 PM: Now using node v16.18.0 (npm v8.19.2)
1:55:33 PM: Enabling node corepack
1:55:33 PM: Started restoring cached build plugins
1:55:33 PM: Finished restoring cached build plugins
1:55:33 PM: Attempting ruby version 2.7.2, read from environment
1:55:34 PM: Using ruby version 2.7.2
1:55:34 PM: Using PHP version 8.0
1:55:34 PM: Started restoring cached yarn cache
1:55:35 PM: Finished restoring cached yarn cache
1:55:35 PM: No yarn workspaces detected
1:55:35 PM: Started restoring cached node modules
1:55:35 PM: Finished restoring cached node modules
1:55:36 PM: Installing NPM modules using Yarn version 1.22.19
1:55:36 PM: yarn install v1.22.19
1:55:36 PM: [1/4] Resolving packages...
1:55:36 PM: [2/4] Fetching packages...
1:55:36 PM: [3/4] Linking dependencies...
1:55:36 PM: warning "@astrojs/mdx > @mdx-js/rollup@2.1.5" has unmet peer dependency "rollup@>=2".
1:55:37 PM: [4/4] Building fresh packages...
1:55:37 PM: Done in 0.99s.
1:55:37 PM: NPM modules installed using Yarn
1:55:37 PM: Started restoring cached go cache
1:55:37 PM: Finished restoring cached go cache
1:55:37 PM: Installing Go version 1.17 (requested 1.17)
1:55:41 PM: unset GOOS;
1:55:41 PM: unset GOARCH;
1:55:41 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.17.linux.amd64';
1:55:41 PM: export PATH="/opt/buildhome/.gimme/versions/go1.17.linux.amd64/bin:${PATH}";
1:55:41 PM: go version >&2;
1:55:41 PM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.17.linux.amd64.env"
1:55:41 PM: go version go1.17 linux/amd64
1:55:41 PM: Installing missing commands
1:55:41 PM: Verify run directory
1:55:42 PM: ​
1:55:42 PM: ────────────────────────────────────────────────────────────────
1:55:42 PM:   Netlify Build                                                 
1:55:42 PM: ────────────────────────────────────────────────────────────────
1:55:42 PM: ​
1:55:42 PM: ❯ Version
1:55:42 PM:   @netlify/build 28.1.1
1:55:42 PM: ​
1:55:42 PM: ❯ Flags
1:55:42 PM:   baseRelDir: true
1:55:42 PM:   buildId: 635369aaf9701c000856673e
1:55:42 PM:   deployId: 635369aaf9701c0008566740
1:55:42 PM: ​
1:55:42 PM: ❯ Current directory
1:55:42 PM:   /opt/build/repo
1:55:42 PM: ​
1:55:42 PM: ❯ Config file
1:55:42 PM:   No config file was defined: using default values.
1:55:42 PM: ​
1:55:42 PM: ❯ Context
1:55:42 PM:   production
1:55:42 PM: ​
1:55:42 PM: ────────────────────────────────────────────────────────────────
1:55:42 PM:   1. Build command from Netlify app                             
1:55:42 PM: ────────────────────────────────────────────────────────────────
1:55:42 PM: ​
1:55:42 PM: $ astro build
1:55:44 PM: 03:55:44 AM [build] output target: static
1:55:44 PM: 03:55:44 AM [build] Collecting build info...
1:55:44 PM: 03:55:44 AM [build] Completed in 362ms.
1:55:44 PM: 03:55:44 AM [build] Building static entrypoints...
1:55:45 PM: 03:55:45 AM [build] Completed in 1.20s.
1:55:45 PM: 
1:55:45 PM:  generating static routes 
1:55:45 PM: ▶ src/pages/index.astro
1:55:45 PM:   └─ /index.html (+7ms)
1:55:45 PM: Completed in 10ms.
1:55:45 PM: 
1:55:45 PM: 03:55:45 AM [build] 1 page(s) built in 1.58s
1:55:45 PM: 03:55:45 AM [build] Complete!
1:55:45 PM: ​
1:55:45 PM: (build.command completed in 2.6s)
1:55:45 PM: ​
1:55:45 PM: ────────────────────────────────────────────────────────────────
1:55:45 PM:   2. Functions bundling                                         
1:55:45 PM: ────────────────────────────────────────────────────────────────
1:55:45 PM: ​
1:55:45 PM: Packaging Functions from .netlify/functions-internal directory:
1:55:45 PM:  - entry.mjs
1:55:45 PM: ​
1:55:45 PM: ✘ [ERROR] Could not resolve "@astrojs/netlify/netlify-functions.js"
1:55:45 PM:     .netlify/functions-internal/entry.mjs:1:25:
1:55:45 PM:       1 │ import * as adapter from '@astrojs/netlify/netlify-functions.js';
1:55:45 PM:         ╵                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1:55:45 PM:   You can mark the path "@astrojs/netlify/netlify-functions.js" as external to exclude it from the bundle, which will remove this error.
1:55:45 PM: ​
1:55:45 PM: ────────────────────────────────────────────────────────────────
1:55:45 PM:   Dependencies installation error                               
1:55:45 PM: ────────────────────────────────────────────────────────────────
1:55:45 PM: ​
1:55:45 PM:   Error message
1:55:45 PM:   A Netlify Function failed to require one of its dependencies.
1:55:45 PM:   Please make sure it is present in the site's top-level "package.json".​
1:55:45 PM:   Build failed with 1 error:
1:55:45 PM:   .netlify/functions-internal/entry.mjs:1:25: ERROR: Could not resolve "@astrojs/netlify/netlify-functions.js"
1:55:45 PM: ​
1:55:45 PM:   Resolved config
1:55:45 PM:   build:
1:55:45 PM:     command: astro build
1:55:45 PM:     commandOrigin: ui
1:55:45 PM:     publish: /opt/build/repo/dist
1:55:45 PM:     publishOrigin: ui
1:55:45 PM: Caching artifacts
1:55:45 PM: Started saving node modules
1:55:45 PM: Finished saving node modules
1:55:45 PM: Started saving build plugins
1:55:45 PM: Finished saving build plugins
1:55:45 PM: Started saving yarn cache
1:55:46 PM: Finished saving yarn cache
1:55:46 PM: Started saving pip cache
1:55:46 PM: Finished saving pip cache
1:55:46 PM: Started saving emacs cask dependencies
1:55:46 PM: Finished saving emacs cask dependencies
1:55:46 PM: Started saving maven dependencies
1:55:46 PM: Finished saving maven dependencies
1:55:46 PM: Started saving boot dependencies
1:55:46 PM: Finished saving boot dependencies
1:55:46 PM: Started saving rust rustup cache
1:55:46 PM: Finished saving rust rustup cache
1:55:46 PM: Started saving go dependencies
1:55:46 PM: Finished saving go dependencies
1:55:46 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
1:55:46 PM: Creating deploy upload records
1:55:46 PM: Failing build: Failed to build site
1:55:47 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
1:55:47 PM: Finished processing build request in 23.070730429s

It still deploys the site, and I’m not sure if/how to ignore this error as per the message. I have no functions, this is a static Astro site without SSR integration installed (as I don’t need/want it).

Any help appreciated, thanks!

Could you share your repo? I don’t see why that would be needed if you’re running a static build, unless this is a bug in Astro.

I had an uncleared .netlify folder from a previous SSR build, which I accidently overlooked, deleting this solved the problem :slight_smile:

2 Likes