尝试加载站点的gatsby-config时遇到错误

时间:2019-10-24 22:40:47

标签: javascript gatsby

当我尝试构建运行npm的项目时,build会引发以下错误:

$ npm run build

> gatsby-starter-mate@2.5.1 build 
  C:\Users\israe\Documents\isra.github.io\gatsby
> gatsby build && npm run clean && cp -a public/* ../


 ERROR #10123  CONFIG

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

我在Windows上重现此问题。

我尝试将假的gatsby-config.js添加到C:\ Users \ israe \ Documents \ isra.github.io \ node_modules \ gatsby-plugin-layout \ gatsby-config,错误消失了,但是对于其他插件抛出相同的错误。

这是完整的错误:

 TypeError: Expected parameter accessToken

  - contentful.node.js:7381 Module.createClient
    [gatsby]/[contentful]/dist/contentful.node.js:7381:11

  - gatsby-config.js:7 Object.<anonymous>
    C:/Users/israe/Documents/isra.github.io/gatsby/gatsby-config.js:7:27

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

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

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

  - loader.js:593 tryModuleLoad
    internal/modules/cjs/loader.js:593:12

  - loader.js:585 Function.Module._load
    internal/modules/cjs/loader.js:585:3

  - loader.js:692 Module.require
    internal/modules/cjs/loader.js:692:17

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

  - get-config-file.js:24 getConfigFile
    [gatsby]/[gatsby]/dist/bootstrap/get-config-file.js:24:20

  - index.js:90 module.exports
    [gatsby]/[gatsby]/dist/bootstrap/index.js:90:36

  - build.js:70 build
    [gatsby]/[gatsby]/dist/commands/build.js:70:13

  - create-cli.js:154 cli.command.handler.getCommandHandler
    [gatsby]/[gatsby]/[gatsby-cli]/lib/create-cli.js:154:14

  - create-cli.js:89 argv
    [gatsby]/[gatsby]/[gatsby-cli]/lib/create-cli.js:89:24

  - create-cli.js:25 Object.args [as handler]
    [gatsby]/[gatsby]/[gatsby-cli]/lib/create-cli.js:25:19

  - command.js:238 Object.runCommand
    [gatsby]/[gatsby]/[yargs]/lib/command.js:238:44


⠋ open and validate gatsby-configs
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! gatsby-starter-mate@2.5.1 build: `gatsby build && npm run clean 
&& cp -a public/* ../`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the gatsby-starter-mate@2.5.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\israe\AppData\Roaming\npm-cache\_logs\2019-10- 
24T22_11_49_686Z-debug.log

这是package.json脚本文件:

{
    "name": "gatsby-starter-mate",
    "version": "2.5.1",
    "description": "Gatsby v2 starter to create a top notch portfolio!",
    "main": "index.js",
    "scripts": {
        "fix-medium-plugin": "sed -i' ' 's/\\/latest//g' 
./node_modules/gatsby-source-medium/gatsby-node.js",
        "prepare": "npm run fix-medium-plugin && gatsby clean",
        "clean": "del -f \"../!(gatsby)*\" && rm -rf public",
        "build": "gatsby build && npm run clean && cp -a public/* ../",
        "develop": "npm run prepare && gatsby develop",
        "start": "npm run develop",
        "serve": "npm run build && gatsby serve -p 9000",
        "lint": "eslint ./src",
        "setup": "node ./bin/setup.js",
        "e2e:open": "cypress open",
        "e2e:ci": "DETERMINISTIC=true start-server-and-test serve 
http://localhost:9000 'percy exec -- cypress run'"
    },

在这里我编辑脚本的一部分,添加一个干净的属性并编辑build属性。

预期结果 丢失的配置文件应妥善处理。

实际结果 他们不是。

0 个答案:

没有答案