javascript - Nuxt 抛出 'The "path"argument must be of type string' or console spam

标签 javascript node.js vue.js nuxt.js babeljs

我在做什么以及出了什么问题

我正在开发一个新项目 ( GitHub repo ),当我尝试运行本地开发服务器时,我遇到了这个错误:

> jakub-suchenek@1.1.0 dev
> nuxt


   ╭───────────────────────────────────────╮
   │                                       │
   │   Nuxt @ v2.15.7                      │
   │                                       │
   │   ▸ Environment: development          │
   │   ▸ Rendering:   server-side          │
   │   ▸ Target:      server               │
   │                                       │
   │   Listening: http://localhost:3000/   │
   │                                       │
   ╰───────────────────────────────────────╯

i Preparing project for development                                                                           19:29:23
i Initial build may take a while                                                                              19:29:23
i Discovered Components: .nuxt/components/readme.md                                                           19:29:23
√ Builder initialized                                                                                         19:29:23

 ERROR  The "path" argument must be of type string. Received undefined                                        19:29:23

  at new NodeError (node:internal/errors:371:5)
  at validateString (node:internal/validators:119:11)
  at Object.extname (node:path:837:5)
  at node_modules\@nuxt\builder\dist\builder.js:413:98
  at Array.map (<anonymous>)
  at Builder.normalizePlugins (node_modules\@nuxt\builder\dist\builder.js:409:28)
  at async Builder.generateRoutesAndFiles (node_modules\@nuxt\builder\dist\builder.js:371:31)
  at async Builder.build (node_modules\@nuxt\builder\dist\builder.js:319:5)
  at async Object._buildDev (node_modules\@nuxt\cli\dist\cli-dev.js:107:5)
  at async Object.startDev (node_modules\@nuxt\cli\dist\cli-dev.js:65:7)
  at async Object.run (node_modules\@nuxt\cli\dist\cli-dev.js:52:5)
  at async NuxtCommand.run (node_modules\@nuxt\cli\dist\cli-index.js:413:7)

但这只有在我的 nuxt.config.js 文件中有这个时才会发生:

plugins: [ "@babel/plugin-proposal-private-property-in-object", { "loose": true }],

没有这个插件配置,我在控制台中有很多垃圾邮件。

plugins: [],

几百次:

 WARN  Though the "loose" option was set to "false" in your @babel/preset-env config, it will not be used for @babel/plugin-proposal-private-property-in-object since the "loose" mode option was set to "true" for @babel/plugin-proposal-private-methods.
The "loose" option must be the same for @babel/plugin-proposal-class-properties, @babel/plugin-proposal-private-methods and @babel/plugin-proposal-private-property-in-object (when they are enabled): you can silence this warning by explicitly adding
        ["@babel/plugin-proposal-private-property-in-object", { "loose": true }]
to the "plugins" section of your Babel config.

我尝试过的

  1. 更改 Nuxt.js 版本(2.152.142.13)。
  2. 正在重新安装 Node 包。

我的问题

最好的解决方案是什么?没有带有“WARN”的控制台垃圾邮件并有一个工作的应用程序。

或者没有解决办法?根据this post ,目前无法避免控制台中出现这些可怕的 WARN 错误。


我的代码:

(在 GitHub 上开源)

最佳答案

这是一个已经修复并等待发布的新错误。

可在此处找到更多信息:Latest Nuxt v2.15.7 install with babel "loose" option warnings

关于javascript - Nuxt 抛出 'The "path"argument must be of type string' or console spam,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68671411/

相关文章:

javascript - jQuery:如何选择所有具有 :before 或 :after 的伪元素元素?

node.js - TypeError : this. props.delItemRow 不是删除项目的函数

node.js - 如何返回url中请求的字符串?

javascript - nuxt vue router afterEach 守卫

css - Vuetify 自定义样式的 vuetify 组件,如带有 css 的 v-textarea

javascript - 尝试从REST API获取数据时,请求的资源上没有“Access-Control-Allow-Origin” header

c# - JSON post 在 IE 中有效,在 FF 中无效

javascript - 区分 AJAX 上的多种表单

javascript - Node JS - 在服务器的来回调用之间保留 session ?

vue.js - Vue - 将所有 Prop 保留在一个大型 mixin 中是否更好