【问题标题】:error with gatsby finding preset "react" when running gatsby develop运行 gatsby develop 时 gatsby 发现预设“react”时出错
【发布时间】:2018-11-13 07:48:30
【问题描述】:

我正试图让 gatsby 制作一个新项目,并希望用它来为新博客提供动力。因此,我下载了 cli,创建了一个新项目,cd 进入该文件夹,并尝试运行“gatsby develop”,这导致我找不到答案的错误。它说它在我的根目录中找不到预设的“反应”。为什么在我的根目录中找不到项目文件夹时,它会在我的根目录中寻找反应?

这是我的终端的样子:

 C:\Users\Kevin Murphy\Desktop\Projects\web-dev-blog  (gatsby-starter-default@1.0.0)
λ gatsby develop
success delete html and css files from previous builds — 0.023 s
success open and validate gatsby-config.js — 0.005 s
success copy gatsby files — 0.022 s
success onPreBootstrap — 0.034 s
success source and transform nodes — 0.018 s
success building schema — 0.111 s
success createLayouts — 0.038 s
success createPages — 0.001 s
success createPagesStatefully — 0.035 s
success onPreExtractQueries — 0.000 s
success update schema — 0.042 s
success extract queries from components — 0.064 s
success run graphql queries — 0.027 s
success write out page data — 0.008 s
success write out redirect data — 0.001 s
success onPostBootstrap — 0.001 s

info bootstrap finished - 4.074 s

error There was an error compiling the html.js component for the development server.

See our docs page on debugging HTML builds for help 


  Error: Module build failed: Error: Couldn't find preset "react" relative to directory "C:\\Users\\Kevi
  n Murphy"

  - option-manager.js:293
    [web-dev-blog]/[babel-core]/lib/transformation/file/options/option-manager.js:293:19

  - Array.map

  - option-manager.js:275 OptionManager.resolvePresets
    [web-dev-blog]/[babel-core]/lib/transformation/file/options/option-manager.js:275:20

  - option-manager.js:264 OptionManager.mergePresets
    [web-dev-blog]/[babel-core]/lib/transformation/file/options/option-manager.js:264:10

  - option-manager.js:249 OptionManager.mergeOptions
    [web-dev-blog]/[babel-core]/lib/transformation/file/options/option-manager.js:249:14

  - option-manager.js:368 OptionManager.init
    [web-dev-blog]/[babel-core]/lib/transformation/file/options/option-manager.js:368:12

  - index.js:212 File.initOptions
    [web-dev-blog]/[babel-core]/lib/transformation/file/index.js:212:65

  - index.js:135 new File
    [web-dev-blog]/[babel-core]/lib/transformation/file/index.js:135:24

  - pipeline.js:46 Pipeline.transform
    [web-dev-blog]/[babel-core]/lib/transformation/pipeline.js:46:16

  - index.js:46 transpile
    [web-dev-blog]/[babel-loader]/lib/index.js:46:20

  - fs-cache.js:79
    [web-dev-blog]/[babel-loader]/lib/fs-cache.js:79:18

  - fs-cache.js:15 ReadFileContext.callback
    [web-dev-blog]/[babel-loader]/lib/fs-cache.js:15:14

【问题讨论】:

    标签: javascript reactjs terminal command-line-interface gatsby


    【解决方案1】:

    也许在您的某个组件或页面中,您从/react 导入react 而不仅仅是react?它应该看起来像 import React from 'react'

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-06-21
      • 1970-01-01
      • 2021-03-16
      • 2020-06-04
      • 2021-06-19
      • 1970-01-01
      • 2022-08-23
      相关资源
      最近更新 更多