admin管理员组

文章数量:1326506

I am making a project with Vite + React and it worked well until the end of last week, but all of a sudden, I got this 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");

I am using macBook air Monterey version 12.5 (M1, 2020), and this below is my package.json

"dependencies": {
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-range": "^1.8.14"
  },
  "devDependencies": {
    "@types/react": "^18.0.28",
    "@types/react-dom": "^18.0.11",
    "@vitejs/plugin-react": "^4.0.0-beta.0",
    "eslint": "^8.38.0",
    "eslint-plugin-react": "^7.32.2",
    "eslint-plugin-react-hooks": "^4.6.0",
    "eslint-plugin-react-refresh": "^0.3.4",
    "sass": "^1.62.0",
    "vite": "^4.3.0"
  }

I tried several ways below to fix this issue.

1. modify Vite.config.js

optimizeDeps: { exclude: ["fsevents"] } In this case, there is no error on the terminal, but I can see only empty screen on the web browser and the console says

caught SyntaxError: Invalid left-hand side in assignment

2. Use loaders

So I tried to use "node-loader' and 'file-loader' to make Vite load '.node' file successfully with changing 'vite.config.js' to apply the rules, but still it didn't work

3. remove lines from vite.config.js

import { resolveBaseUrl } from 'vite';

import { defineConfig } from "vite";

I found these two suggestions from other questions in Stack Overflow but the first line I didn't even have, and the other one gives me error:

caught SyntaxError: Invalid left-hand side in assignment (at ${mod.url}${sourceMapSuffix}`);:32482:5)

4. Remove Node and reinstall it

I removed node and all the relevant files and check that there's no more node, and reinstalled node, but again not working

FYI: While trying these, I removed 'node_modules' and re-installed

If anyone can help me to solve this issue, I would really appreciate it. Thank you in advance for any suggestions!

I am making a project with Vite + React and it worked well until the end of last week, but all of a sudden, I got this 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");

I am using macBook air Monterey version 12.5 (M1, 2020), and this below is my package.json

"dependencies": {
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-range": "^1.8.14"
  },
  "devDependencies": {
    "@types/react": "^18.0.28",
    "@types/react-dom": "^18.0.11",
    "@vitejs/plugin-react": "^4.0.0-beta.0",
    "eslint": "^8.38.0",
    "eslint-plugin-react": "^7.32.2",
    "eslint-plugin-react-hooks": "^4.6.0",
    "eslint-plugin-react-refresh": "^0.3.4",
    "sass": "^1.62.0",
    "vite": "^4.3.0"
  }

I tried several ways below to fix this issue.

1. modify Vite.config.js

optimizeDeps: { exclude: ["fsevents"] } In this case, there is no error on the terminal, but I can see only empty screen on the web browser and the console says

caught SyntaxError: Invalid left-hand side in assignment

2. Use loaders

So I tried to use "node-loader' and 'file-loader' to make Vite load '.node' file successfully with changing 'vite.config.js' to apply the rules, but still it didn't work

3. remove lines from vite.config.js

import { resolveBaseUrl } from 'vite';

import { defineConfig } from "vite";

I found these two suggestions from other questions in Stack Overflow but the first line I didn't even have, and the other one gives me error:

caught SyntaxError: Invalid left-hand side in assignment (at ${mod.url}${sourceMapSuffix}`);:32482:5)

4. Remove Node and reinstall it

I removed node and all the relevant files and check that there's no more node, and reinstalled node, but again not working

FYI: While trying these, I removed 'node_modules' and re-installed

If anyone can help me to solve this issue, I would really appreciate it. Thank you in advance for any suggestions!

Share Improve this question edited Apr 24, 2023 at 14:52 Olivia asked Apr 24, 2023 at 14:04 OliviaOlivia 1473 silver badges9 bronze badges 2
  • did you ever figure this out? I'm stuck with the same issue. – Michael H Commented Nov 20, 2023 at 16:13
  • ^ Wondering about this too? This failure started happening to me all of a sudden, and can't find what I might have done to cause it. – ttiurani Commented Nov 30, 2023 at 11:31
Add a ment  | 

3 Answers 3

Reset to default 5

I had the same issue, and i found that vscode has accidentally imported the loadConfigFromFile method somewhere in my project and that had been the issue.

Try looking for other imports from 'vite' where they shouldn't be.

Credit: this GitHub issue ment

check, if some modules requires to run only on server side. for me this error happened when i tried to import { getPlatformProxy } from "wrangler" from my client api service. When i removed it, error disapeared

(i used official Cloudflare Remix template)

I had this problem working with tsup. Despite trying every solution I found, digging into esbuild options from tsup (like external or plugins) I couldn't get it to work.

I found a remnant of some experiments in my tsconfig.json:

"pilerOptions": {
  ...
  "paths": {
    "*": ["./*"]
  },
}

which was meant to ensure the imports work without extensions (which I personally dislike), but it actually caused that loader problem.

It must have done something else that caused imports to work without extensions and this paths expression is no longer needed.

It's a nightmare, I sympathize with anyone who runs into this sorts of problems.

本文标签: