简体   繁体   English

当我为 gatsby-starter-gcn 运行 gatsby develop 时,如何修复错误 #10123?

[英]How to fix Error #10123 when I run gatsby develop for gatsby-starter-gcn?

I'm trying to use gatsby-starter-gcn to create a website.我正在尝试使用 gatsby-starter-gcn 创建网站。 At this point I just want to be able to view the starter site locally so I can begin to make edits.此时,我只想能够在本地查看起始站点,以便开始进行编辑。 But when I run gatsby develop I get the following error:但是当我运行gatsby develop时,出现以下错误:

ERROR #10123  CONFIG

We encountered an error while trying to load your site's gatsby-config. Please fix the error and try again.



  Error: Contentful space ID and access token need to be provided.

  - gatsby-config.js:14 Object.<anonymous>
    C:/Windows/system32/gatsby-starter-gcn/gatsby-config.js:14:11

  - v8-compile-cache.js:178 Module._compile
    [gatsby-starter-gcn]/[v8-compile-cache]/v8-compile-cache.js:178:30

  - loader.js:1220 Object.Module._extensions..js
    internal/modules/cjs/loader.js:1220:10

  - loader.js:1049 Module.load
    internal/modules/cjs/loader.js:1049:32

  - loader.js:937 Function.Module._load
    internal/modules/cjs/loader.js:937:14

  - loader.js:1089 Module.require
    internal/modules/cjs/loader.js:1089:19

  - v8-compile-cache.js:159 require
    [gatsby-starter-gcn]/[v8-compile-cache]/v8-compile-cache.js:159:20

  - get-config-file.js:33 getConfigFile
    [gatsby-starter-gcn]/[gatsby]/dist/bootstrap/get-config-file.js:33:20

  - index.js:134 module.exports
    [gatsby-starter-gcn]/[gatsby]/dist/bootstrap/index.js:134:46

  - develop-process.js:433 module.exports
    [gatsby-starter-gcn]/[gatsby]/dist/commands/develop-process.js:433:36

  - task_queues.js:97 processTicksAndRejections
    internal/process/task_queues.js:97:5


not finished open and validate gatsby-configs - 0.052s

I tried to open the gatsby-config.js file in order to see the problem.我试图打开 gatsby-config.js 文件以查看问题。 I could open it in Notepad just fine, but Windows Script Host returned this error: Line: 1 Char: 5 Error: Expected ';'我可以在记事本中打开它就好了,但是 Windows 脚本主机返回了这个错误: Line: 1 Char: 5 Error: Expected ';' Code: 800A03EC Source: Microsoft JScript compilation error代码:800A03EC 来源:Microsoft JScript 编译错误

I think if I can fix this compilation error in this file my problem will probably be fixed, but I haven't been able to figure out how, since I'm not terribly experienced with javascript.我想如果我能在这个文件中修复这个编译错误,我的问题可能会得到解决,但我无法弄清楚如何解决,因为我对 javascript 的经验并不丰富。 Here's a link to the file on GitHub: https://github.com/ryanwiemer/gatsby-starter-gcn/blob/master/gatsby-config.js这是 GitHub 上文件的链接: https://github.com/ryanwiemer/gatsby-starter-gcn/blob/master/gatsby-config.js

It looks like the error is being thrown because you may not have a .env file in your repository or windows environment variables set with your contentful SPACE_ID, ACCESS_TOKEN.似乎正在引发错误,因为您的存储库中可能没有.env文件,或者使用内容丰富的 SPACE_ID ACCESS_TOKEN 设置了 windows 环境变量。

https://github.com/ryanwiemer/gatsby-starter-gcn/blob/master/gatsby-config.js#L7 https://github.com/ryanwiemer/gatsby-starter-gcn/blob/master/gatsby-config.js#L7

Creating those variables should get this building for you.创建这些变量应该会为您建立这个建筑物。

I believe you need an .env file with SPACE_ID and ACCESS_TOKEN at the root of your project.我相信您在项目的根目录中需要一个带有SPACE_IDACCESS_TOKEN.env文件。

The project requires a .contentful.json config file to be created in the root of the project.该项目需要在项目的根目录中创建一个.contentful.json配置文件。 You can run npm run setup or yarn setup to have it walk you through the creation with you providing Contentful API key info.您可以运行npm run setupyarn setup ,让它引导您完成创建,并提供 Contentful API 关键信息。 After that, running gatsby develop should work fine.之后,运行gatsby develop应该可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM