Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

Issue with running Storybook project from Sanity examples directory.

17 replies
Last updated: May 8, 2021
Hi, I'm trying to run the Storybook project from the Sanity examples directory (https://github.com/sanity-io/sanity/tree/next/examples/storybook ). After installing all dependencies (tried
lerna bootstrap
and
npm
as well as
yarn
), and starting the server, I get many Module not found: Error: Can't resolve
@sanity/
related errors - at least 32 of them - even if the dependencies seem to be installed correctly.
May 8, 2021, 12:06 PM
After running
lerna bootstrap
from the root of the repo, I try to start the app, but get this error:
storybook % npm start            

> storybook@2.10.2 start
> sanity start --port 9002

@sanity/core not installed in current project
Project-specific commands not available until you run `sanity install`

Error: "start" is not available outside of a Sanity project context.
Run the command again within a Sanity project directory, where "@sanity/core"
is installed as a dependency.

May 8, 2021, 12:07 PM
Even though
node_modules/@sanity/core
is installed - I can see it being there. I continue as suggested above:
storybook % sanity install
✖ Resolving dependencies Fetching packages
✖ An unexpected error occurred: "ENOENT: no such file or directory, lstat '/Users/fabien/Development/sanity/sanity-development/examples/storybook/node_modules/@sanity/base/node_modules/polished/node_modules'".
✖ Resolving dependenciesinking dependencies

Error: Command failed :(
May 8, 2021, 12:09 PM
Proceeding with
npm i
and running
sanity install
once again, I can finally start the server:
⠦ Compiling...Storybook listening on <http://localhost:9001/>
⠙ Compiling...webpack built d1935283b7fceb260a1a in 7327ms
✔ Compiling...
Failed to compile.
Followed by numerous
Module not found: Error: Can't resolve ...
errors.
May 8, 2021, 12:11 PM
I got this working with
yarn
followed by
sanity start
. Perhaps give that a try with a clean version of the directory?
May 8, 2021, 2:49 PM
Hi Geoff, did you run
lerna bootstrap
first?
May 8, 2021, 2:50 PM
No. I don’t have lerna installed globally and don’t see it anywhere in the package.
May 8, 2021, 2:50 PM
Unfortunately, no success. I deleted
node_modules
and
package-lock.json
and
yarn.lock
.
May 8, 2021, 2:56 PM
What’s the latest error now? Is it when running
yarn
or
sanity start
?
May 8, 2021, 3:19 PM
What’s the latest error now? Is it when running
yarn
or
sanity start
?
May 8, 2021, 3:19 PM
Still all the compilation errors due to missing dependencies (so after
sanity start
)
May 8, 2021, 3:28 PM
Still all the compilation errors due to missing dependencies (so after
sanity start
)
May 8, 2021, 3:28 PM
Sorry Fabien. I tried different versions of node and yarn and couldn’t replicate the error.
May 8, 2021, 3:36 PM
That's odd - thanks for checking this. I'm on Node
v14.15.0
. Did you simply clone the full repo and go to that directory and ran
yarn
?
May 8, 2021, 3:38 PM
I tried on 14.16.1, 15.12.0, and 16.1.0. I downloaded the whole sanity repo then pulled out the storybook folder and worked on it in isolation.
May 8, 2021, 3:45 PM
Let me try that in isolation - I have a feeling that this lerna thing is still causing havoc here.
May 8, 2021, 3:46 PM
Sure enough, it's now working (pulled it from a zip file of the repo). Thanks for all your help!
May 8, 2021, 3:51 PM
Nice! Glad to hear it.
May 8, 2021, 3:54 PM

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.

Was this answer helpful?