【问题标题】:Nuxt generate does not generate index.htmlNuxt generate 不生成 index.html
【发布时间】:2021-05-23 11:57:50
【问题描述】:

我在本地机器上有一个 Nuxt JS 项目,如果我启动它,它可以正常工作...但是当我尝试在 dist 文件夹中创建文件以将其复制到我的 Linux 服务器上时,它没有工作,因为没有 index.html....这里是它生成的一个镜头:

如您所见,没有生成 index.html....

我们的配置是默认的 nuxt 配置....如果你能帮助我会很好:)

【问题讨论】:

    标签: node.js npm nuxt.js


    【解决方案1】:

    如果您的pages/index.vue 中有一些语法错误,这通常会发生。 nuxt:generate 不会在出错时停止生成过程,而只会跳过这一条路线。这让你失去了一条路线。

    但是,您应该在控制台中收到与此类似的错误消息:

    [...]
    
    ℹ Generating pages with full static mode                                                                                      12:22:37
    
     ERROR   /                                                                                                                    12:22:37
    
    ReferenceError: window is not defined
        at pages/index.js:2832:31
        at pages/index.js:1252:10
        at Object.<anonymous> (node_modules/dat.gui/build/dat.gui.js:18:0)
        at __webpack_require__ (webpack/bootstrap:25:0)
        at Module.<anonymous> (components/scene/App.js:1:0)
        at __webpack_require__ (webpack/bootstrap:25:0)
        at Module.<anonymous> (pages/index.js:4603:11)
        at __webpack_require__ (webpack/bootstrap:25:0)
        at Module.<anonymous> (pages/index.vue?b245:27:0)
        at __webpack_require__ (webpack/bootstrap:25:0)
        at async server.js:3496:21
        at async Promise.all (index 0)
        at async getRouteData (node_modules/.cache/nuxt/utils.js:181:0)
        at async Promise.all (index 0)
        at async setContext (node_modules/.cache/nuxt/utils.js:259:0)
        at async createApp (node_modules/.cache/nuxt/index.js:150:0)
    
    ✔ Generated route "/sitemap"                                                                                                  12:22:43
    ✔ Generated route "/search"
    
    [...]
    

    您也可以使用nuxt generate --fail-on-error。 (见https://nuxtjs.org/docs/2.x/get-started/commands/#fail-on-error

    【讨论】:

      猜你喜欢
      • 2021-03-28
      • 2020-05-30
      • 2018-02-20
      • 1970-01-01
      • 2019-01-19
      • 2021-03-06
      • 2020-12-02
      • 1970-01-01
      • 2019-04-19
      相关资源
      最近更新 更多