Warning and error messages after running sanity start, resolved by performing npm i.

2 replies
Last updated: Apr 8, 2021
Hello. After I did sanity upgrade, I'm getting the following warning on running sanity start:

Warning in ./node_modules/@sanity/ui/dist/es/utils/layer/layerProvider.js
11:30-43 "export 'useMediaIndex' was not found in 
'../../hooks'
 @ ./node_modules/@sanity/ui/dist/es/utils/layer/layerProvider.js
 @ ./node_modules/@sanity/ui/dist/es/utils/layer/index.js
 @ ./node_modules/@sanity/ui/dist/es/utils/index.js
 @ ./node_modules/@sanity/ui/dist/es/index.js     
 @ ./node_modules/@sanity/base/lib/components/SanityRoot.js (part:@sanity/base/sanity-root)
 @ ./node_modules/@sanity/server/lib/browser/entry-dev.js
 @ multi ./node_modules/normalize.css/normalize.css ./node_modules/@sanity/server/lib/browser/entry-dev.js
It still starts the studip, but crashes again when trying to open in the browser.

Console shows the following error:


Uncaught TypeError: Object(...) is not a function
    at LayerProvider (layerProvider.js:11)
    at renderWithHooks (react-dom.development.js:14804)
    at mountIndeterminateComponent (react-dom.development.js:17483)
    at beginWork (react-dom.development.js:18597)
    at HTMLUnknownElement.callCallback (react-dom.development.js:189)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:238)
    at invokeGuardedCallback (react-dom.development.js:293)
    at beginWork$1 (react-dom.development.js:23204)
    at performUnitOfWork (react-dom.development.js:22155)
    at workLoopSync (react-dom.development.js:22131)

react-dom.development.js:19528 The above error occurred in the <LayerProvider> component:
    in LayerProvider (created by AppProvider)
    in PortalProvider (created by AppProvider)
    in UserColorManagerProvider (created by AppProvider)
    in AppProvider (created by SanityRoot)
    in Ge (created by ThemeProvider)
    in ThemeProvider (created by SanityRoot)
    in ZIndexProvider (created by SanityRoot)
    in SanityRoot
    in AppContainer

React will try to recreate this component tree from scratch using the error boundary you provided, AppContainer.
Apr 8, 2021, 10:10 AM
Seems to work now, after I performed npm i to see if it helped ๐Ÿ™‚
Apr 8, 2021, 11:59 AM
npm i seems to be a bit of a panacea in the studio, haha.
Apr 8, 2021, 4:32 PM

Sanity โ€“ Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?