首页 > 解决方案 > 在生产构建中启用 Nuxt 源映射

问题描述

我最近在 Nuxt 中构建了一个通用并部署了它。但是我一直遇到这个错误:

[nuxt] Error while initializing app DOMException: "Node cannot be inserted at the specified point in the hierarchy" app.3bc9463ad06cdf9b6df1.js:formatted:2195
T23V/<
app.3bc9463ad06cdf9b6df1.js:formatted:2195
a
https://wca.findleds.com/_nuxt/vendor.6debe2bdce1d595803d9.js:2:242000
M/<
https://wca.findleds.com/_nuxt/vendor.6debe2bdce1d595803d9.js:2:242145
l
https://wca.findleds.com/_nuxt/vendor.6debe2bdce1d595803d9.js:2:105265
TypeError: "n.setAttribute is not a function"
nrhttps://wca.findleds.com/_nuxt/vendor.6debe2bdce1d595803d9.js:2:43662xhttps://wca.findleds.com/_nuxt/vendor.6debe2bdce1d595803d9.js:2:54236xhttps://wca.findleds.com/_nuxt/vendor.6debe2bdce1d595803d9.js:2:54466xhttps://wca.findleds.com/_nuxt/vendor.6debe2bdce1d595803d9.js:2:54316xhttps://wca.findleds.com/_nuxt/vendor.6debe2bdce1d595803d9.js:2:54466xhttps://wca.findleds.com/_nuxt/vendor.6debe2bdce1d595803d9.js:2:54316Krhttps://wca.findleds.com/_nuxt/vendor.6debe2bdce1d595803d9.js:2:56066_updatehttps://wca.findleds.com/_nuxt/vendor.6debe2bdce1d595803d9.js:2:34144mounthttps://wca.findleds.com/_nuxt/vendor.6debe2bdce1d595803d9.js:2:63373gethttps://wca.findleds.com/_nuxt/vendor.6debe2bdce1d595803d9.js:2:18466runhttps://wca.findleds.com/_nuxt/vendor.6debe2bdce1d595803d9.js:2:19357Eehttps://wca.findleds.com/_nuxt/vendor.6debe2bdce1d595803d9.js:2:17495tehttps://wca.findleds.com/_nuxt/vendor.6debe2bdce1d595803d9.js:2:13945Zthttps://wca.findleds.com/_nuxt/vendor.6debe2bdce1d595803d9.js:2:13447 vendor.6debe2bdce1d595803d9.js:2:13331

我在开发中没有遇到任何错误。我什至配置了生产服务器的重复版本,但没有收到错误。我对.nuxt文件夹进行了比较,并没有什么不同寻常的地方。

源地图在这里会非常有用,但我无法加载它们。如何在 ? 中启用源nuxt.config.js映射NODE_ENV = production

标签: javascriptwebpack

解决方案


可以通过扩展 nuxt webpack 配置(参见https://nuxtjs.org/docs/2.x/configuration-glossary/configuration-build#extend)启用 nuxt prod 构建的源映射,如下所示:

export default {
  build: {
    extend(config) {
      config.devtool = 'source-map'
    }
  }
}

推荐阅读