I have a Next.js project that uses the Prismic CMS, and the site works locally just fine, but recently someone changed some copy in a document and that's resulting in the following Traceback in the production builds:
2:42:19 PM: /opt/build/repo/node_modules/@prismicio/helpers/dist/documentToLinkField.cjs:9
2:42:19 PM: uid: prismicDocument.uid ?? void 0,
2:42:19 PM: ^
2:42:19 PM: SyntaxError: Unexpected token '?'
2:42:19 PM: at wrapSafe (internal/modules/cjs/loader.js:1054:16)
2:42:19 PM: at Module._compile (internal/modules/cjs/loader.js:1102:27)
2:42:19 PM: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
2:42:19 PM: at Module.load (internal/modules/cjs/loader.js:986:32)
2:42:19 PM: at Function.Module._load (internal/modules/cjs/loader.js:879:14)
2:42:19 PM: at Module.require (internal/modules/cjs/loader.js:1026:19)
2:42:19 PM: at require (internal/modules/cjs/helpers.js:72:18)
2:42:19 PM: at Module.<anonymous> (/opt/build/repo/node_modules/@prismicio/helpers/dist/asLink.cjs:4:29)
2:42:19 PM: at Module._compile (internal/modules/cjs/loader.js:1138:30)
2:42:19 PM: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10) {
2:42:19 PM: type: 'SyntaxError'
In my code itself using @prismicio/client
, I am creating a Client object:
import * as prismic from "@prismicio/client";
const repositoryName = process.env.NEXT_PUBLIC_PRISMIC_REPO_NAME;
const endpoint = prismic.getRepositoryEndpoint(repositoryName);
export const createClient = () => {
return prismic.createClient(endpoint, {
accessToken: process.env.PRISMIC_ACCESS_TOKEN,
});
};
and later, I am using the client by pulling in content from a UID I created:
let contentBlob = await client.getByUID("customUID", params.partner);
This works well locally, and all of the copy changes are reflected in the local rendered output. Besides deleting and/or recreating documents and adding in logs where I can, are there best practices for debugging this (somewhat mysterious) Prismic error?