2

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!

Olivia
  • 97
  • 1
  • 7

1 Answers1

1

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 comment

lcabraja
  • 11
  • 1
  • Thank you ! It took me until I saw your message to see that VS Code had automatically imported something it should not have. – Maxime Deuse Jul 16 '23 at 13:54