小编Sty*_*war的帖子

在 Cpanel 中部署 Api NodeJ 时出现 503 错误

所以我已经部署了我的网站 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)

javascript deployment node.js

6
推荐指数
0
解决办法
686
查看次数

类型“UseMutationResult &lt;AxiosResponse &lt;any,any&gt;,Error,void,unknown&gt;”上不存在属性“isLoading”。ts(2339)

我正在尝试创建一个删除函数,其中它将显示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)

typescript reactjs next.js

2
推荐指数
1
解决办法
1398
查看次数

标签 统计

deployment ×1

javascript ×1

next.js ×1

node.js ×1

reactjs ×1

typescript ×1