没有在 node_modules 中配置加载程序 (fsevents)

huangapple go评论116阅读模式
英文:

No loader is configured in node_modules (fsevents)

问题

I'm using Vite v4.1.1 with Vue 3.2 and all of a sudden got the following error message while running npm run dev:

[ERROR] No loader is configured for ".node" files: node_modules/fsevents/fsevents.node

    node_modules/fsevents/fsevents.js:13:23:
      13 │ const Native = require("./fsevents.node");
         ╵                        ~~~~~~~~~~~~~~~~~

More error details:

Error: Build failed with 1 error:
errors: [
    {
      detail: undefined,
      id: '',
      location: {
        column: 23,
        file: 'node_modules/fsevents/fsevents.js',
        length: 17,
        line: 13,
        lineText: 'const Native = require("./fsevents.node");',
        namespace: '',
        suggestion: ''
      },
      notes: [],
      pluginName: '',
      text: 'No loader is configured for ".node" files: node_modules/fsevents/fsevents.node'
    }
  ],
  warnings: []
}

Node.js v19.6.0

I tried the [fix](https://stackoverflow.com/questions/75640753/vite-esbuild-error-no-loader-is-configured-for-node-files-node-modules-fs) suggested here with no luck, it just introduces more errors with even less explanation.

<details>
<summary>英文:</summary>

I&#39;m using Vite v4.1.1 with Vue 3.2 and all of a sudden got the following error message while running `npm run dev`:

[ERROR] No loader is configured for ".node" files: node_modules/fsevents/fsevents.node

node_modules/fsevents/fsevents.js:13:23:
  13 │ const Native = require(&quot;./fsevents.node&quot;);
     ╵                        ~~~~~~~~~~~~~~~~~

More error details:

Error: Build failed with 1 error:
errors: [
{
detail: undefined,
id: '',
location: {
column: 23,
file: 'node_modules/fsevents/fsevents.js',
length: 17,
line: 13,
lineText: 'const Native = require("./fsevents.node");',
namespace: '',
suggestion: ''
},
notes: [],
pluginName: '',
text: 'No loader is configured for ".node" files: node_modules/fsevents/fsevents.node'
}
],
warnings: []
}

Node.js v19.6.0



I tried the [fix](https://stackoverflow.com/questions/75640753/vite-esbuild-error-no-loader-is-configured-for-node-files-node-modules-fs) suggested here with no luck, it just introduces more errors with even less explanation.

</details>


# 答案1
**得分**: 2

以下是翻译好的内容:

这可能与每个人都无关,但我在Svelte应用程序中遇到了完全相同的错误,并且原因是错误的导入。

我曾经有:

```typescript
import { defineConfig } from "vite";

我的IDE不小心自动导入了这个。删除这个导入修复了问题。

英文:

This might not be relevant to everyone, but I just had this exact error pop up in a Svelte app, and the cause turned out to be an erroneous import.

I had:

import { defineConfig } from &quot;vite&quot;;

which I my IDE had accidentally auto imported. Removing the import fixed the issue.

答案2

得分: 2

只移除以下部分来解决这个错误:

"import { resolveBaseUrl } from 'vite';"
英文:

Resolved this error by just removing -

&quot;import { resolveBaseUrl } from &#39;vite&#39;;&quot;

which was imported by itself or maybe accidentally while importing something!

huangapple
  • 本文由 发表于 2023年3月7日 18:46:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/75660981.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定