Site name: strong-eclair-a3020a - this site isn’t deployed yet.
When running this site locally I don’t encounter any problems but when I try deploying at Netlify I get this error:
Build log:
1:19:27 PM: Netlify Build
1:19:27 PM: ────────────────────────────────────────────────────────────────
1:19:27 PM:
1:19:27 PM: ❯ Version
1:19:27 PM: @netlify/build 29.33.5
1:19:27 PM:
1:19:27 PM: ❯ Flags
1:19:27 PM: baseRelDir: true
1:19:27 PM: buildId: 65c0d1f3191198116d52139d
1:19:27 PM: deployId: 65c0d1f3191198116d52139f
1:19:27 PM:
1:19:27 PM: ❯ Current directory
1:19:27 PM: /opt/build/repo
1:19:27 PM:
1:19:27 PM: ❯ Config file
1:19:27 PM: No config file was defined: using default values.
1:19:27 PM:
1:19:27 PM: ❯ Context
1:19:27 PM: production
1:19:27 PM:
1:19:27 PM: Build command from Netlify app
1:19:27 PM: ────────────────────────────────────────────────────────────────
1:19:27 PM:
1:19:27 PM: $ npm run build
1:19:27 PM: > accessible-astro-starter@3.1.2 build
1:19:27 PM: > astro build
1:19:28 PM: 12:19:28 [build] output: “static”
1:19:28 PM: 12:19:28 [build] directory: /opt/build/repo/dist/
1:19:28 PM: 12:19:28 [build] Collecting build info…
1:19:28 PM: 12:19:28 [build] ✓ Completed in 82ms.
1:19:28 PM: 12:19:28 [build] Building static entrypoints…
1:19:31 PM: 12:19:31 [astro-icon] Loaded icons from ion, mdi
1:19:31 PM: 12:19:31 [WARN] [vite] [plugin:vite:reporter]
1:19:31 PM: (!) /opt/build/repo/src/layouts/MarkdownLayout.astro is dynamically imported by /opt/build/repo/src/pages/mdx-page.mdx but also statically imported by /opt/build/repo/src/pages/markdown-page.md, dynamic import will not move module into another chunk.
1:19:31 PM:
1:19:31 PM: 12:19:31 [build] ✓ Completed in 3.18s.
1:19:31 PM: building client (vite)
1:19:31 PM: 12:19:31 [vite] transforming…
1:19:32 PM: 12:19:32 [vite] ✓ 14 modules transformed.
1:19:32 PM: 12:19:32 [vite] rendering chunks…
1:19:32 PM: 12:19:32 [vite] computing gzip size…
1:19:32 PM: 12:19:32 [vite] dist/astro/hoisted.g7Bov203.js 17.57 kB │ gzip: 5.95 kB
1:19:32 PM: 12:19:32 [vite] ✓ built in 128ms
1:19:32 PM: generating static routes
1:19:32 PM: 12:19:32 src/pages/404.astro
1:19:32 PM: 12:19:32 └─ /404.html (+10ms)
1:19:32 PM: 12:19:32 src/pages/accessible-components.astro
1:19:32 PM: 12:19:32 └─ /accessible-components/index.html (+10ms)
1:19:32 PM: 12:19:32 src/pages/event/[post].astro
1:19:32 PM: undefined
1:19:32 PM: Cannot read properties of undefined (reading “map”)
1:19:32 PM: Stack trace:
1:19:32 PM: at Module.getStaticPaths$1 [as getStaticPaths] (file:///opt/build/repo/dist/chunks/prerender-hgn8ZaV.mjs:667:15)
1:19:32 PM: at async callGetStaticPaths (file:///opt/build/repo/node_modules/astro/dist/core/render/route-cache.js:28:17)
1:19:32 PM: at async generatePage (file:///opt/build/repo/node_modules/astro/dist/core/build/generate.js:241:19)
1:19:32 PM: at async staticBuild (file:///opt/build/repo/node_modules/astro/dist/core/build/static-build.js:96:7)
1:19:32 PM: at async AstroBuilder.run (file:///opt/build/repo/node_modules/astro/dist/core/build/index.js:169:7)
1:19:32 PM: at async build (file:///opt/build/repo/node_modules/astro/dist/cli/build/index.js:20:3)
1:19:32 PM: at async cli (file:///opt/build/repo/node_modules/astro/dist/cli/index.js:155:5)
1:19:32 PM:
1:19:32 PM: “build.command” failed
1:19:32 PM: ────────────────────────────────────────────────────────────────
1:19:32 PM:
1:19:32 PM: Error message
1:19:32 PM: Command failed with exit code 1: npm run build (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)
1:19:32 PM:
1:19:32 PM: Error location
1:19:32 PM: In Build command from Netlify app:
1:19:32 PM: npm run build
1:19:32 PM:
1:19:32 PM: Resolved config
1:19:32 PM: build:
1:19:32 PM: command: npm run build
1:19:32 PM: commandOrigin: ui
1:19:32 PM: environment:
1:19:32 PM: - DATOCMS_API_KEY
1:19:32 PM: - DATO_API_TOKEN
1:19:32 PM: publish: /opt/build/repo/dist
1:19:32 PM: publishOrigin: ui
1:19:33 PM: Failed during stage “building site”: Build script returned non-zero exit code: 2
1:19:33 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
1:19:33 PM: Failing build: Failed to build site
1:19:33 PM: Finished processing build request in 54.324s
It seems to be a problem with the function getStaticPaths. My code in [post].astro looks like this:
import DefaultLayout from ‘…/…/layouts/DefaultLayout.astro’
import { Breadcrumbs, BreadcrumbsItem, Media } from ‘accessible-astro-components’
export async function getStaticPaths() {
const response = await fetch(‘https://graphql.datocms.com/’, {
method: ‘POST’,
headers: {
‘Content-Type’: ‘application/json’,
Accept: ‘application/json’,
Authorization: Bearer ${import.meta.env.DATOCMS_API_KEY}
,
},
body: JSON.stringify({
query: query BlogPosts { allBlogPosts { id title body eventStartDate image { url } } }
,
}),
});
const json = await response.json();
const data = json.data.allBlogPosts;
console.log(data)
return data.map((post) => {
return {
params: { post: post.title.replaceAll(’ ', ‘-’).toLowerCase() },
props: { post },
}
})
}
const { post } = Astro.props
{post.title}
Evenemanget startar: {post.eventStartDate}
{post.body}
Has anyone encountered the same problems?