最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

reactjs - Vite Build Error: Could not load useAuthStore (ENOENT: no such file or directory) - Stack Overflow

programmeradmin2浏览0评论

I'm trying to deploy my project on Render, but I'm facing an issue during the build process, and I can't seem to figure out the root cause. Here's the error:

[vite:load-fallback] Could not load /opt/render/project/src/frontend/src/store/useAuthStore (imported by src/App.jsx): ENOENT: no such file or directory, open '/opt/render/project/src/frontend/src/store/useAuthStore'
    at async open (node:internal/fs/promises:638:25)
    at async Object.readFile (node:internal/fs/promises:1238:14)
    at async Object.load (file:///opt/render/project/src/frontend/node_modules/vite/dist/node/chunks/dep-M1IYMR16.js:50719:25)
    at async PluginDriver.hookFirstAndGetPlugin (file:///opt/render/project/src/frontend/node_modules/rollup/dist/es/shared/node-entry.js:20840:28)
    at async file:///opt/render/project/src/frontend/node_modules/rollup/dist/es/shared/node-entry.js:19963:33
    at async Queue.work (file:///opt/render/project/src/frontend/node_modules/rollup/dist/es/shared/node-entry.js:21050:32)

What I've Tried

  • Checked for the file

    • Checked the src/store/ directory, and the useAuthStore.js file does exist. The file is committed to GitHub and available in the repository. Checked the import paths:

    • In my App.jsx, I have this line: import useAuthStore from './store/useAuthStore';

    • Since the file doesn't exist, I removed the import entirely, but Vite still seems to reference it during the build.

  • Cleaned the environment:

    • Deleted node_modules, .vite, and dist folders.
    • Reinstalled dependencies with npm install.
    • Ran the build locally using npm run build—it, works perfectly fine on my machine.
  • Checked the Render environment:

    • Verified that all files are committed to GitHub and there’s no .gitignore issue.
    • The issue only occurs during deployment on Render, not locally.
  • Ran npm audit fix:

    • Addressed several vulnerabilities, but the issue remains.
发布评论

评论列表(0)

  1. 暂无评论