由于Rollup,Heroku构建在git推送时失败

piok6c0g  于 2022-12-13  发布在  Git
关注(0)|答案(1)|浏览(147)

我正在部署我的第一个Heroku应用程序(NodeJS),但是当它到达最后一个'git push heroku master'步骤时,我得到了一个错误,导致构建失败,因为rollupjs的问题。我甚至不认为我在我的应用程序中使用了Rollup,我甚至尝试了全局和依赖卸载Rollup,看看它是否会改变什么,但是没有。我该如何解决这个问题?

remote: Could not resolve './sections/Home.jsx' from src/main.jsx
remote: error during build:
remote: Error: Could not resolve './sections/Home.jsx' from src/main.jsx
remote:     at error (file:///tmp/build_544c0c85/node_modules/vite/node_modules/rollup/dist/es/shared/rollup.js:1858:30)
remote:     at ModuleLoader.handleResolveId (file:///tmp/build_544c0c85/node_modules/vite/node_modules/rollup/dist/es/shared/rollup.js:22350:24)
remote:     at file:///tmp/build_544c0c85/node_modules/vite/node_modules/rollup/dist/es/shared/rollup.js:22313:26
remote: 
remote: -----> Build failed

main.jsx:

import React from 'react'
import ReactDOM from 'react-dom/client'
import Home from './sections/Home.jsx'
import { BrowserRouter, Routes, Route } from "react-router-dom"

ReactDOM.createRoot(document.getElementById('root')).render(
  <React.StrictMode>
      <BrowserRouter>
        <Routes>
          <Route path="/" element={<Home />}>
          </Route>
        </Routes>
      </BrowserRouter>
  </React.StrictMode>
)

Home.jsx:

import React from "react";
import About from "./About";
import Projects from "./Projects";
import Landing from "./Landing";
import Navbar from './Navbar'
import Skills from "./Skills";
import Footer from './Footer'
import Contact from "./Contact"
import { useState } from "react";
import { useEffect } from "react";
import '../App.css'

function Home() {
    const [darkTheme, setDarkTheme] = useState(true)
    const [darkLand, setDarkLand] = useState(true)
    const [count, setCount] = useState(0)

    const prefersDarkScheme = window.matchMedia("(prefers-color-scheme: dark)");
    const currentTheme = localStorage.getItem("theme");
    if (currentTheme == "dark") {
      document.body.classList.toggle("light-theme");
      setDarkTheme(true)
      setCount(count + 1)
    } else if (currentTheme == "light") {
      document.body.classList.toggle("dark-theme");
      setDarkTheme(false)
      setCount(count + 1)
    }
    
    function themeChange() {
      if (prefersDarkScheme.matches) {
        document.body.classList.toggle("light-theme");
        setDarkTheme(true)
        setCount(count + 1)
      } else {
        document.body.classList.toggle("dark-theme");
        setDarkTheme(false)
        setCount(count + 1)
      }
    };

    useEffect(() => {
        setDarkLand(!darkLand)
    }, [count])


    return(
        <div className="Home fade" id="home" key={darkTheme}>
            <Navbar themeChange={themeChange} darkLand={darkLand} />
            <Landing darkLand={darkLand} key={darkLand}/>
            <About />
            <Skills />
            <Projects />
            <Contact />
            <Footer />
        </div>
    )
}

export default Home
z0qdvdin

z0qdvdin1#

Mac和Windows(您可能正在使用其中一个进行开发)有不区分大小写的文件系统。Linux(您正在部署到其中)有区分大小写的文件系统。./sections/Home.jsx可以在您的计算机上工作,但在Heroku上不行-请将其更改为./Sections/Home.jsx。还有一个个人提示,如果您想避免类似的问题,您可以为自己设置一个规则,始终使用小写的文件名和目录。

相关问题