Build error with Next.js Personal Website template and @sanity/ui 1.0.6
13 replies
Last updated: Jan 10, 2023
E
Following up on build errors I was running into recently – I’ve tried deploying the Next.js Personal Website template to vercel without any issue, but when I go to clone it to my local machine and run
I’m wondering if anyone else has experienced this error on build. There must be some issue with my development environment though I can’t seem to trace it. I’m running Node 19.3.0
yarn buildi get the following error
Module parse failed: 'import' and 'export' may appear only with 'sourceType: module' (61:0) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See <https://webpack.js.org/concepts#loaders> | function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } | function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } > import { jsx, jsxs, Fragment } from 'react/jsx-runtime'; | import { useMemo, useState, useRef, useEffect, createContext, useContext, useLayoutEffect, forwardRef, useId, useCallback, cloneElement, isValidElement, createElement, Component, memo, useReducer, Children, Fragment as Fragment$1 } from 'react'; | import ReactIs, { isElement as isElement$1, isFragment, isValidElementType } from 'react-is'; Import trace for requested module: ./node_modules/@sanity/ui/dist/index.esm.js ./node_modules/sanity/lib/index.esm.js ./sanity.config.ts ./app/studio/[[...index]]/page.tsx
Dec 29, 2022, 6:51 PM
S
Did you clone it locally?
Dec 29, 2022, 6:52 PM
S
And if yes, did you also install and linking your clone to vercel and sanity before trying to build? (Just asking, because we had some cases where these steps were skipped 😉 )
Dec 29, 2022, 6:53 PM
E
hi
user J
thanks for the reply, yes I’ve ran vercel linkand
vercel env pullalready
Dec 29, 2022, 6:53 PM
S
and installed all dependencies?
Dec 29, 2022, 6:54 PM
E
mmhm, my steps to reproduce this error are
>> clone from github repo yarn npx vercel link npx vercel env pull yarn build
Dec 29, 2022, 6:55 PM
E
hoping someone can reproduce this
Dec 29, 2022, 7:40 PM
E
i’m running macos ventura with m1 if that makes any difference
Dec 29, 2022, 7:51 PM
It seems to be an issue with
@sanity/ui@1.0.6(though I haven’t yet confirmed). Could you please add the following to your package.json, then trash your node_modules and lock file and try again? We will bring this to the Engineering team for a resolution.
"resolutions": { "@sanity/ui": "1.0.5" }
Dec 29, 2022, 7:59 PM
E
user A
I was able to run yarn devand
yarn buildsuccessfully with your suggestion, ty!
Dec 29, 2022, 8:02 PM
Great! Glad to hear you’re up and running. A fix may not be possible until next week but it’s good to know this is a workaround in the meantime.
Dec 29, 2022, 8:04 PM
M
this also worked for me! had a similar error today. thanks!
Dec 29, 2022, 8:13 PM
S
This looks similar to the issue I ran into here . Npm isn’t as aggressive about updating versions as yarn is. See my thread for my findings and the issues I filed. I didn’t narrow the issue down to @sanity/ui, so this thread is very useful! Thanks
user A
!Dec 31, 2022, 12:33 AM
R
Hi, add the same issue with import and now it’ s ok with code below
"resolutions": { "@sanity/ui": "1.0.5" }
Jan 10, 2023, 12:08 AM
Sanity– build remarkable experiences at scale
Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.