如何修复找不到模块“ gatsby-cli / lib / reporter”?

时间:2019-06-18 23:10:04

标签: javascript node.js reactjs npm gatsby

我遇到了盖茨比问题。 当我运行Error: Cannot find module 'gatsby-cli/lib/reporter'时,显示gatsby develop处于沙色状态。我该如何解决,请回答

E:\JavaScript\gatsby-js> gatsby develop
success open and validate gatsby-configs - 0.008 s
error Error in "E:\JavaScript\gatsby-js\node_modules\gatsby-source-filesystem\gatsby-node.js":


  Error: Cannot find module 'gatsby-cli/lib/reporter'
  Require stack:
  - E:\JavaScript\gatsby-js\node_modules\gatsby-source-filesystem\utils.js
  - E:\JavaScript\gatsby-js\node_modules\gatsby-source-filesystem\create-file-node.js
  - E:\JavaScript\gatsby-js\node_modules\gatsby-source-filesystem\gatsby-node.js
  - E:\JavaScript\gatsby-js\node_modules\gatsby\dist\bootstrap\resolve-module-exports.js
  - E:\JavaScript\gatsby-js\node_modules\gatsby\dist\bootstrap\load-plugins\validate.js
  - E:\JavaScript\gatsby-js\node_modules\gatsby\dist\bootstrap\load-plugins\load.js
  - E:\JavaScript\gatsby-js\node_modules\gatsby\dist\bootstrap\load-plugins\index.js
  - E:\JavaScript\gatsby-js\node_modules\gatsby\dist\bootstrap\index.js
  - E:\JavaScript\gatsby-js\node_modules\gatsby\dist\commands\develop.js
  - C:\Users\Shayon\AppData\Roaming\npm\node_modules\gatsby-cli\lib\create-cli.js
  - C:\Users\Shayon\AppData\Roaming\npm\node_modules\gatsby-cli\lib\index.js

  - loader.js:623 Function.Module._resolveFilename
    internal/modules/cjs/loader.js:623:15

  - loader.js:527 Function.Module._load
    internal/modules/cjs/loader.js:527:27

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

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

  - utils.js:15 Object.<anonymous>
    [gatsby-js]/[gatsby-source-filesystem]/utils.js:15:18

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

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

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

  - loader.js:556 Function.Module._load
    internal/modules/cjs/loader.js:556:12

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

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

  - create-file-node.js:7 Object.<anonymous>
    [gatsby-js]/[gatsby-source-filesystem]/create-file-node.js:7:18

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

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

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

  - loader.js:556 Function.Module._load
    internal/modules/cjs/loader.js:556:12

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

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

  - gatsby-node.js:12 Object.<anonymous>
    [gatsby-js]/[gatsby-source-filesystem]/gatsby-node.js:12:19

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

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

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


⠋ load plugins

4 个答案:

答案 0 :(得分:1)

作为立即的解决方法,您可以使用yarn代替npm

rm -rf node_modules
yarn
gatsby develop

此处的解决方案:https://github.com/gatsbyjs/gatsby/issues/14875

答案 1 :(得分:1)

我遇到了与您相同的问题。使用以下方法将缺少的模块安装到您的项目中:

npm install --save gatsby-cli

解决方案来自 https://github.com/gatsbyjs/gatsby/issues/4131

答案 2 :(得分:1)

删除 node-modules package-lock.json ,然后通过运行 npm install 重新安装它们。固定我的!✔️

答案 3 :(得分:0)

谢谢你们。 你们真的很有帮助。 为仍然面临问题的人回答这个问题。

尝试一下 对于Linux

sudo gatsby new gatsby-site
cd gatsby-site
sudo gatsby develop

对于Windows,以管理员身份运行命令提示符,然后输入应该可以使用的命令

gatsby new gatsby-site
cd gatsby-site
gatsby develop