【问题标题】:Nuxt throws 'The "path" argument must be of type string' or console spamNuxt 抛出'“路径”参数必须是字符串类型'或控制台垃圾邮件
【发布时间】:2021-10-10 17:56:44
【问题描述】:

我在做什么和出了什么问题

我正在开发一个新项目 (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.15、2.14、2.13)。
  2. 重新安装节点包。

我的问题

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

还是没有解决办法?根据this post 的说法,目前无法在控制台中不出现这些可怕的 WARN 错误。


我的代码:

(在 GitHub 上开源)

【问题讨论】:

    标签: javascript node.js babeljs nuxt.js


    【解决方案1】:

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

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

    【讨论】:

    • 我已经在帖子中提到过,但感谢您的快速回复。
    • 这里在配置方面给出了解决方案。
    猜你喜欢
    • 2020-08-02
    • 2021-01-27
    • 1970-01-01
    • 1970-01-01
    • 2020-08-12
    • 2020-10-21
    • 1970-01-01
    • 2021-06-24
    • 1970-01-01
    相关资源
    最近更新 更多