所以我已经部署了我的网站 Nodejs + MySQL,但问题是我收到错误
503 Service Unavailable The server is temporarily busy, try again later!
所以我看到了一个线程:相反,将index.js的需求更改为所有CommonJS模块中都可用的动态导入(),我按照该线程并安装了
npm i node-fetch@2.6.1
之后,我也返回到我的setup nodejs并停止该过程,然后npm install再次收到相同的错误,当我检查我的时,stderr.log我收到此错误
/usr/local/lsws/fcgi-bin/lsnode.js:48 var app = require(startupFile); ^
Error [ERR_REQUIRE_ESM]: require() of ES Module /home/ppsconl2/nodejs/index.js from /usr/local/lsws/fcgi-bin/lsnode.js not supported.
Instead change the require of index.js in /usr/local/lsws/fcgi-bin/lsnode.js to a dynamic import() which is available in all CommonJS modules.
at startApplication (/usr/local/lsws/fcgi-bin/lsnode.js:48:15)
at Object.<anonymous> (/usr/local/lsws/fcgi-bin/lsnode.js:16:1) {
code: 'ERR_REQUIRE_ESM'
}
Run Code Online (Sandbox Code Playgroud)
这是我的 package.json
{
"name": …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个删除函数,其中它将显示tanstackquery 的loading state使用useMutate,但问题是当我删除按钮时,即使我更改了网络速度,它也不会显示加载状态。
const ButtonAction = ({ id }: ButtonActionProps) => {
const router = useRouter();
const { mutate: deletePost, isLoading } = useMutation({
mutationFn: () => {
return axios.delete(`/api/posts/${id}`);
},
onError: (error) => {
console.error(error);
},
onSuccess: () => {
router.push("/");
router.refresh();
},
});
return (
<div>
<Link href="/edit/1" className="btn mr-2">
{" "}
<Pencil /> Edit
</Link>
<button onClick={() => deletePost()} className="btn btn-error">
{" "}
{isLoading && (
<span className="loading loading-spinner loaddeing-xs"></span>
)}
{isLoading ? …Run Code Online (Sandbox Code Playgroud)