Skip to content

Build error occurred ReferenceError: Cannot access 'api' before init #193

@stelasido

Description

@stelasido

npm i
yarn

npm run build
yarn build

and that error:
`
1:/var/www/blog/next-cms-ghost$ npm run build

next-cms-ghost@1.0.0 build
next build

info - Loaded env from /var/www/blog/next-cms-ghost/.env.local
info - Checking validity of types
info - Creating an optimized production build
info - Compiled successfully

Build error occurred
ReferenceError: Cannot access 'api' before initialization
at getAllPosts (/var/www/blog/next-cms-ghost/.next/server/chunks/393.js:454:19)
at getStaticPaths (/var/www/blog/next-cms-ghost/.next/server/pages/[...slug].js:1591:90)
at buildStaticPaths (/var/www/blog/next-cms-ghost/node_modules/next/dist/build/utils.js:498:37)
at /var/www/blog/next-cms-ghost/node_modules/next/dist/build/utils.js:641:125
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Span.traceAsyncFn (/var/www/blog/next-cms-ghost/node_modules/next/dist/trace/trace.js:75:20) {
type: 'ReferenceError'
}`

`lsb_release -a

Distributor ID: Ubuntu
Description: Ubuntu 22.04.2 LTS
Release: 22.04

NVM with a supported for GhostCMS version 18.6 or above, it doesn't matter.

.env.local:
CMS_GHOST_API_URL=......
CMS_GHOST_API_KEY=......

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions