提问人:Owenn 提问时间:8/15/2023 最后编辑:Owenn 更新时间:10/20/2023 访问量:1243
NextJS - TypeError:保存 SASS 文件时无法读取 null 的属性(读取“removeChild”)
NextJS - TypeError: Cannot read properties of null (reading 'removeChild') when saving SASS file
问:
我收到这样的错误:
Unhandled Runtime Error
TypeError: Cannot read properties of null (reading 'removeChild')
Call Stack
HTMLLinkElement.eval
node_modules/next/dist/compiled/mini-css-extract-plugin/hmr/hotModuleReplacement.js (1:1136)
当我编辑 SASS 文件时会发生这种情况,但应用程序会正确热重新加载并且一切正常。只是这个错误有点困扰我。这可能是什么?
请注意,我目前正在使用 NextJS 13。
我的完整代码在这里
布局.js
import "./globals.scss";
import { dmSans } from "./fonts";
export default function RootLayout({ children }) {
return (
<html lang="en">
<body>
<div className={`${dmSans.variable}`}>{children}</div>
</body>
</html>
);
}
页面.js
"use client";
import { useEffect } from "react";
import ShortDescription from "@/components/short-description";
import SelectedWork from "@/components/selected-work";
import RotatingText from "@/components/rotating-text";
import pguImage from "@/public/pgu.webp";
import adaroImage from "@/public/adaro.webp";
import petraImage from "@/public/petra.webp";
import styles from "./page.module.scss";
import { gsap } from "gsap";
export default function Home() {
useEffect(() => {
gsap.to("#hero > * > *", {
duration: 1,
y: 0,
opacity: 1,
stagger: 0.25,
ease: "power2",
});
}, []);
return (
<div id="main-container">
<header className={styles.header}>
<span className={styles.header__title}>OWENN GIMLI</span>
</header>
<div className={`${styles.hero} container`} id="hero">
<div>
<h4>\\ Personal portfolio</h4>
</div>
<div>
<h1>DATA SCIENCE,</h1>
</div>
<div>
<h1>WEB DEVELOPMENT</h1>
</div>
<div>
<h1>& DESIGN.</h1>
</div>
</div>
</div>
);
}
答:
0赞
FireFly
9/18/2023
#1
恐怕我没有解决方案,但我也遇到了这个问题。我在搜索中发现了这个:https://github.com/webpack-contrib/mini-css-extract-plugin/issues/682 声称类似的问题已得到解决。
我的代码也可以运行和上传,并且在任何地方都不能使用!removeChild
对不起,我没有解决办法,如果我想通了,我会让你知道,但我只是想让你知道你并不孤单:)
-1赞
tomheffels
10/3/2023
#2
冒着听起来像下图中的那个人的风险......我在开发中一遍又一遍地遇到同样的错误,但是当我杀死我的进程并重新启动它时,它似乎已经消失了。有时就是这么简单,希望这也能为您解决!npm run dev
评论
0赞
Owenn
10/4/2023
不行哈哈,我尝试重新启动服务器,但每次保存SASS文件时,它仍然会给我抛出相同的错误。
2赞
Ayoub Wazane
10/20/2023
#3
我今天在尝试使用SASS文件时遇到了同样的错误。我解决问题的方法是删除文件夹并重新启动服务器。.next
评论
removeChild
module