【问题标题】:Gatsby - Error: Cannot find module '..\node_modules\gatsby\dist\utils\babel-loader.js'Gatsby - 错误:找不到模块 '..\node_modules\gatsby\dist\utils\babel-loader.js'
【发布时间】:2021-12-31 12:50:01
【问题描述】:

当运行gatsby develop,在gatsby new 之后使用本教程中提供的配置 - https://www.gatsbyjs.com/docs/tutorial/part-1/,我收到此错误

模块构建失败(来自 ../../my-first-gatsby-sitenode_modules/gatsby/dist/utils/babel-loader.js): 错误:找不到模块 '..\my-first-gatsby-site\node_modules\gatsby\dist\utils\babel-loader.js'

我尝试过的解决方案:

  1. 删除 node_modules、package-lock => npm install / yarn。
  2. node_modules/gatsby 中运行npm install
  3. npm -g --save babel-loader。

如果您遇到错误并能够解决它,请提供帮助。 TIA。

【问题讨论】:

    标签: javascript node.js gatsby


    【解决方案1】:

    node_modules/gatsby 中运行npm install

    npm install 必须在项目的根目录中运行,而不是在 node_modules 中。

    删除 node_modules, package-lock => npm install / yarn.

    你应该只选择 npm 或 yarn,不能同时选择。

    尝试以下方法:

    • 运行以下命令:npm install --save gatsby-cli
    • 如果您在上一个命令之前有很多审核警告,请运行:npm audit fix(在项目的根目录中)。
    • 删除您的node_modules 并重新安装项目根目录中的依赖项:npm install

    【讨论】:

    • 我试过了,但问题仍然存在
    猜你喜欢
    • 1970-01-01
    • 2018-02-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-11
    • 2021-11-11
    • 2023-02-20
    • 1970-01-01
    • 2019-01-12
    相关资源
    最近更新 更多