-
Notifications
You must be signed in to change notification settings - Fork 19
Error: sanity.cli.ts does not contain a project identifier #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think this is an issue with the latest sanity cli because when you use a js file instead of ts then it does work |
In my case (and probably most of you too if you've followed Sanity's setup for NextJS), the issue is that I read these variables from the environment. import { defineCliConfig } from "sanity/cli";
const projectId = process.env.NEXT_PUBLIC_SANITY_PROJECT_ID;
const dataset = process.env.NEXT_PUBLIC_SANITY_DATASET;
export default defineCliConfig({
api: { projectId, dataset },
}); Providing those in the - name: Export Dataset
uses: sanity-io/[email protected]
with:
args: dataset export [DATASET] [UPLOAD_FILE_PATH]
env:
SANITY_AUTH_TOKEN: [TOKEN]
NEXT_PUBLIC_SANITY_PROJECT_ID: [PROJECT_ID]
NEXT_PUBLIC_SANITY_DATASET: [DATASET] Alternatively, you could also have a step that deletes the file and rewrites it with the values populated: - run: |
rm sanity.cli.ts && echo 'export default { api: { projectId: "PROJECT_ID", dataset: "DATASET" } }' > sanity.cli.ts However, I then got a new error, which has been reported here: #23 . The workaround suggested by this comment fixed the new error. This was my final configuration to make it work with the latest CLI (3.43.0): - name: Export dataset
run: npx sanity dataset export ${{ inputs.dataset || 'production' }} ${{ steps.upload_name.outputs.UPLOAD_NAME }}
env:
SANITY_AUTH_TOKEN: ${{ secrets.SANITY_TOKEN }}
NEXT_PUBLIC_SANITY_PROJECT_ID: ${{ secrets.SANITY_PROJECT_ID }}
NEXT_PUBLIC_SANITY_DATASET: ${{ inputs.dataset || 'production' }} |
I have the same issue and it seems to be connected to Node.js |
also getting this on a project I recently updated from v1 to v3.. |
Not the exact issue but closely related. It's not working on Node 23 while < 23 works fine. "The requested module 'sanity/cli' does not provide an export named 'defineCliConfig'" The default export |
I am getting the error: "Error: sanity.cli.ts does not contain a project identifier ("api.projectId"), which is required for the Sanity CLI to communicate with the Sanity API"
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The workflow should succeed
Screenshots
Which versions of Sanity are you using?
v3.21.3
The text was updated successfully, but these errors were encountered: