首页 > 解决方案 > Gatsby 项目在开发中有效,但在部署时出现错误(netlify,zeit)

问题描述

我的 gatsby 项目有这样的结构:

    Project
          node_modules
          plugins
                gatsby-source-cloud       // Local Plugin with code from scratch
                        node_modules
                        gatsby-node.js
                        package.json
                        utis.js
          public
          src
          gatsby-config.js // Here one of the plugins resolve to the local plugin above
          gatsby-node.js
          package.json 

这段代码在开发环境中完美运行,但是在部署到github后尝试投入生产(netlify,zeit)时,抛出错误:

嵌套在本地插件 (plugins/gatsby-source-cloud/gatsby-node.js) 中的 gatsby-node.js 在嵌套的 node_modules (pugins/gatsby-source-cloud/node_modules) 中找不到一个模块。

标签: node-modulesgatsbynetlify

解决方案


您无法部署 Gatsby 源代码。您必须运行gatsby build和部署 HTML、CSS 和 JS 的输出。

看看https://www.gatsbyjs.org/docs/deploying-and-hosting/


推荐阅读