0

我有一个同时使用GatsbyKentico Kontent的项目。我一直在使用本地机器(Windows 10)gatsby developnpm run develop我的本地机器(Windows 10)上进行开发。通常,输出如下所示:

$ npm run develop

success open and validate gatsby-configs - 0.169s
success load plugins - 0.426s
success onPreInit - 0.004s
success initialize cache - 0.007s
success copy gatsby files - 0.067s
success onPreBootstrap - 1.357s
success createSchemaCustomization - 0.545s
success source and transform nodes - 1.740s
success building schema - 0.358s
success createPages - 0.068s
success createPagesStatefully - 0.063s
success onPreExtractQueries - 0.002s
success update schema - 0.030s   
success extract queries from components - 0.177s
success write out requires - 0.027s
success write out redirect data - 0.007s
success onPostBootstrap - 0.003s
⠀
info bootstrap finished - 7.596 s
⠀
success run queries - 0.125s - 61/61 489.34/s
⠀
You can now view <project name> in the browser.
⠀
  http://localhost:8000/
⠀
View GraphiQL, an in-browser IDE, to explore your site's data and schema
⠀
  http://localhost:8000/___graphql
⠀
Note that the development build is not optimized.
To create a production build, use gatsby build
⠀
success Building development bundle - 3.319s

当我运行gatsby buildornpm run build时,总是失败,我看到以下错误/输出:

$ npm run build

> <project name>@1.1.1 build C:\projects\<client>\<project name>
> gatsby build

success open and validate gatsby-configs - 0.155s
success load plugins - 0.435s
success onPreInit - 0.004s
success delete html and css files from previous builds - 0.019s
success initialize cache - 0.008s
success copy gatsby files - 0.076s
success onPreBootstrap - 0.028s

 ERROR #11321  PLUGIN

"@kentico/gatsby-source-kontent" threw an error while running the createSchemaCustomization lifecycle:



not finished createSchemaCustomization - 0.549s
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! <project name>@1.1.1 build: `gatsby build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the <project name>@1.1.1 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\mattn\AppData\Roaming\npm-cache\_logs\2020-03-24T12_10_17_984Z-debug.log

查看建议的日志文件,我看到:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'build'
1 verbose cli ]
2 info using npm@6.13.4
3 info using node@v12.16.1
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle <project name>@1.1.1~prebuild: <project name>@1.1.1
6 info lifecycle <project name>@1.1.1~build: <project name>@1.1.1
7 verbose lifecycle <project name>@1.1.1~build: unsafe-perm in lifecycle true
8 verbose lifecycle <project name>@1.1.1~build: PATH: <My Env Variables Path>
9 verbose lifecycle <project name>@1.1.1~build: CWD: C:\projects\<client>\<project name>
10 silly lifecycle <project name>@1.1.1~build: Args: [ '/d /s /c', 'gatsby build' ]
11 silly lifecycle <project name>@1.1.1~build: Returned: code: 1  signal: null
12 info lifecycle <project name>@1.1.1~build: Failed to exec build script
13 verbose stack Error: working-at-ridgeway@1.1.1 build: `gatsby build`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:311:20)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:311:20)
13 verbose stack     at maybeClose (internal/child_process.js:1021:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid <project name>@1.1.1
15 verbose cwd C:\projects\<client>\<project name>
16 verbose Windows_NT 10.0.18362
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
18 verbose node v12.16.1
19 verbose npm  v6.13.4
20 error code ELIFECYCLE
21 error errno 1
22 error <project name>@1.1.1 build: `gatsby build`
22 error Exit status 1
23 error Failed at the <project name>@1.1.1 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

是否有其他方法可以获取有关错误的详细信息以便我找到解决方案?我已经尝试更新和安装 npm 包并在该 gatsby 项目上运行“清理”,但似乎没有任何帮助。

4

2 回答 2

1

该问题导致@kentico/gatsby-source-kontent版本 6的新日志记录功能。

所以只需运行gatsby develop --verbose,或者gatsby build --verbose从包中获取日志到终端。

官方信息 实施细则

于 2020-05-18T09:17:49.430 回答
0

这只是在黑暗中拍摄,但是,我相信开发配置使用与生产构建不同的环境变量(如果使用客户端 javascript)。你能尝试调整环境吗?根据盖茨比的文档变量?你使用什么操作系统?在访问Linux 和 Windows 的 .env 变量方面也存在一些显着差异。

如果这不起作用,您能否在GitHub 存储库中创建一个问题并提供重现的步骤(或项目)?谢谢!

编辑:我也会尝试使用Gatsby 的环境。变量插件

于 2020-03-24T13:14:40.953 回答