web3templates/stablo

Unable to import demo data

davidric opened this issue · 5 comments

Hi, I found the issue when trying to setup the project. But I have already handled it. I write this issue just for feedback.

So I was trying to import the demo data just like in the given instruction to import data, but I got this error:

$ sanity dataset import .sanity-template/data/production.tar.gz production

Error: Command "dataset" is not available outside of a Sanity project context.
Run the command again within a Sanity project directory, where "sanity"
is installed as a dependency.
    at CommandRunner.runCommand (/usr/local/share/.config/yarn/global/node_modules/@sanity/cli/lib/_chunks/cli-519443c4.js:17742:33506)
    at Object.runCli (/usr/local/share/.config/yarn/global/node_modules/@sanity/cli/lib/_chunks/cli-519443c4.js:17745:2460)

I managed to handle that issue by modifying the import script in package.json:

From:

"import": "sanity dataset import .sanity-template/data/production.tar.gz production",

To:

"import": "cd studio && sanity dataset import ../.sanity-template/data/production.tar.gz production",

After that, I got another error message saying:

$ cd studio && sanity dataset import ../.sanity-template/data/production.tar.gz production
✔ [100%] Fetching available datasets
✔ [100%] Reading/validating data file (45ms)
✖ [  0%] Importing documents (960ms)

Error: Mutation(s) failed with 1 error(s)
You probably want either:
 --replace (replace existing documents with same IDs)
 --missing (only import documents that do not already exist)
    at Object.action (~/Development/manhajsalaf/studio/node_modules/@sanity/core/lib/commands/dataset/importDatasetCommand.js:181:21)
error Command failed with exit code 1.

It seems by default, the sanity won't allow us to import the data to the existing dataset, in this case, production. So we have to add the --replace argument when executing the import script, like this: npm run import --replace.

After that, It ran as expected.

I'm so happy using this template, the theme is so beautiful, easy to manage, and has good performance. Thank you so much for providing this template. Love it!

Thanks for the notes @davidric.

Same issue for me... above steps were not a fix. 😕

@gomesdigital have you already install sanity globally before following the step above?

npm install -g @sanity/cli

Thanks @davidric

I will make a note of this for the next update.

@gomesdigital Could you elaborate your issue with screenshot or error message?

Global install didn't work for me.

💻 🏕️

  • PopOS 22.04
  • Node v14.21.1 via NVM

Solved By:

  1. Adding as a dependency:
    yarn add @sanity/client@^2.11.0

  2. Updating import script in package.json from:
    "import": "sanity dataset import .sanity-template/data/production.tar.gz production",

    to:
    "import": "cd studio && sanity dataset import ../.sanity-template/data/production.tar.gz production",
    as @davidric mentions.

Cheers. 🙌

It should be fixed in v2 release.