[英]Gatsby development server stops working when repo is created on github. Sanity, Gatsby Error
I received a github repo backup from somebody elses account.我从其他人的帐户收到了 github 回购备份。 The project is running gatsby, sanity cms and is hosted via netlify.该项目正在运行 gatsby、sanity cms,并通过 netlify 托管。 When I extract the archive and saving the folder locally, I am perfectly able to get the gatsby development server runnning just by doing "yarn install" and "yarn gatsby develop".当我提取存档并在本地保存文件夹时,我完全可以通过执行“yarn install”和“yarn gatsby develop”来运行 gatsby 开发服务器。
However, when I create a new repo and import the project to my github account, the development server is not running anymore.但是,当我创建一个新的 repo 并将项目导入我的 github 帐户时,开发服务器不再运行。 We tried it on several machines and we always get the same error in terminal trying "yarn gatsby develop".我们在几台机器上尝试过,在终端尝试“yarn gatsby develop”时总是遇到同样的错误。
success open and validate gatsby-configs - 0.131s success load plugins - 2.486s success onPreInit - 0.038s success initialize cache - 0.009s success copy gatsby files - 0.091s info [sanity] Fetching remote GraphQL schema ERROR #gatsby-source-sanity_drafts.10003 [sanity] The token specified is not valid or has been deleted
How is that possible?这怎么可能? I tried to fix this for days but I don't get it.我试图解决这个问题好几天,但我不明白。 The only differnce between being able to run the dev server and this error is to save the code to github... Is it maybe some sort of routing problem in the gatsby-config.js?能够运行开发服务器和此错误之间的唯一区别是将代码保存到 github ... 可能是 gatsby-config.js 中的某种路由问题?
Would appreciate your help a lot!非常感谢您的帮助!
It seems that you are missing the environment variables in your new projects so your Sanity configuration is not valid, hence Gatsby is not able to fetch the data from the sources.您似乎缺少新项目中的环境变量,因此您的 Sanity 配置无效,因此 Gatsby 无法从源中获取数据。
There should be a .env.development
or .env.production
files in your original code placed in the root of the project.在项目根目录下的原始代码中应该有一个.env.development
或.env.production
文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.