关于nuxt2引入three.js页面刷新报错问题
刷新后页面提示:
文章来源:https://www.toymoban.com/news/detail-817806.html
require() of ES Module
three.js is treated as an ES module file as it is a .js file whose nearest parent package.json
contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead rename three.js to end in .cjs, change the requiring code to use dynamic import()
which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs"
in D:\XX\XXXXX\node_modules\three\package.json to treat all .js files as CommonJS
问题所在:
这与 nuxt 构建系统有关。使用第三方库时,应该将它们添加到 nuxt.config.js build.transpile
数组中,以便它可以作为 Babel 的依赖项包含在内。文章来源地址https://www.toymoban.com/news/detail-817806.html
build: {
transpile: ["three"]
}
到了这里,关于nuxt2引入three.js页面刷新报错问题:require() of ES Module的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!