TypeError: process.versions.node is undefined

问题描述 投票:0回答:0

我有一个 Next.js 动态路由,它正在获取 2 个东西:context.query 和来自 Supabase 的一行。这是路由

getServerSideProps
功能的代码
[username].js
页面使用Auth0进行认证,所以我在
withPageAuthRequired
中使用了
getServerSideProps

export const getServerSideProps = withPageAuthRequired({
  async getServerSideProps(context) {
    // const session = getSession(context.req, context.res);
    const username = context.query.username;
    console.log(username);
    const { data, error } = await supabase
      .from("Users")
      .select()
      .eq("username", username);

    if (error || data.length == 0) {
      console.log(data);
      return {
        notFound: true,
      };
    }
    console.log(data);
    return {
      props: data[0],
    };
  },
});

我确实运行了一些目录级别和全局级别的 npm 更新,但我不知道为什么当代码在服务器端运行时节点版本显示为未定义。

如果有帮助,这里是完整的错误消息:

Call Stack
<unknown>
node_modules/oidc-token-hash/lib/shake256.js (3:23)
./node_modules/oidc-token-hash/lib/shake256.js
file:/Users/vidit/GitHubProjects/squawk-components/.next/static/chunks/pages/user/%5Busername%5D.js (958:1)
options.factory
/_next/static/chunks/webpack.js (691:31)
__webpack_require__
file:/Users/vidit/GitHubProjects/squawk-components/.next/static/chunks/webpack.js (37:33)
fn
/_next/static/chunks/webpack.js (346:21)
<unknown>
node_modules/oidc-token-hash/lib/index.js (5:25)
./node_modules/oidc-token-hash/lib/index.js
file:/Users/vidit/GitHubProjects/squawk-components/.next/static/chunks/pages/user/%5Busername%5D.js (948:1)
options.factory
/_next/static/chunks/webpack.js (691:31)
__webpack_require__
file:/Users/vidit/GitHubProjects/squawk-components/.next/static/chunks/webpack.js (37:33)
fn
/_next/static/chunks/webpack.js (346:21)
<unknown>
node_modules/openid-client/lib/client.js (9:26)
./node_modules/openid-client/lib/client.js
file:/Users/vidit/GitHubProjects/squawk-components/.next/static/chunks/pages/user/%5Busername%5D.js (968:1)
options.factory
/_next/static/chunks/webpack.js (691:31)
__webpack_require__
file:/Users/vidit/GitHubProjects/squawk-components/.next/static/chunks/webpack.js (37:33)
fn
/_next/static/chunks/webpack.js (346:21)
<unknown>
node_modules/openid-client/lib/issuer.js (5:26)
./node_modules/openid-client/lib/issuer.js
file:/Users/vidit/GitHubProjects/squawk-components/.next/static/chunks/pages/user/%5Busername%5D.js (1208:1)
options.factory
/_next/static/chunks/webpack.js (691:31)
__webpack_require__
file:/Users/vidit/GitHubProjects/squawk-components/.next/static/chunks/webpack.js (37:33)
fn
/_next/static/chunks/webpack.js (346:21)
<unknown>
node_modules/openid-client/lib/index.js (1:23)
./node_modules/openid-client/lib/index.js
file:/Users/vidit/GitHubProjects/squawk-components/.next/static/chunks/pages/user/%5Busername%5D.js (1198:1)
options.factory
/_next/static/chunks/webpack.js (691:31)
__webpack_require__
file:/Users/vidit/GitHubProjects/squawk-components/.next/static/chunks/webpack.js (37:33)
fn
/_next/static/chunks/webpack.js (346:21)
<unknown>
node_modules/@auth0/nextjs-auth0/dist/auth0-session/transient-store.js (4:30)
./node_modules/@auth0/nextjs-auth0/dist/auth0-session/transient-store.js
file:/Users/vidit/GitHubProjects/squawk-components/.next/static/chunks/pages/user/%5Busername%5D.js (128:1)
options.factory
/_next/static/chunks/webpack.js (691:31)
__webpack_require__
file:/Users/vidit/GitHubProjects/squawk-components/.next/static/chunks/webpack.js (37:33)
fn
/_next/static/chunks/webpack.js (346:21)
<unknown>
node_modules/@auth0/nextjs-auth0/dist/auth0-session/index.js (21:32)
./node_modules/@auth0/nextjs-auth0/dist/auth0-session/index.js
file:/Users/vidit/GitHubProjects/squawk-components/.next/static/chunks/pages/user/%5Busername%5D.js (84:1)
options.factory
/_next/static/chunks/webpack.js (691:31)
__webpack_require__
file:/Users/vidit/GitHubProjects/squawk-components/.next/static/chunks/webpack.js (37:33)
fn
/_next/static/chunks/webpack.js (346:21)
<unknown>
node_modules/@auth0/nextjs-auth0/dist/index.js (6:30)
./node_modules/@auth0/nextjs-auth0/dist/index.js
file:/Users/vidit/GitHubProjects/squawk-components/.next/static/chunks/pages/user/%5Busername%5D.js (315:1)
options.factory
/_next/static/chunks/webpack.js (691:31)
__webpack_require__
file:/Users/vidit/GitHubProjects/squawk-components/.next/static/chunks/webpack.js (37:33)
fn
/_next/static/chunks/webpack.js (346:21)
<unknown>
webpack-internal:///./src/pages/user/[username].jsx (22:96)
./src/pages/user/[username].jsx
file:/Users/vidit/GitHubProjects/squawk-components/.next/static/chunks/pages/user/%5Busername%5D.js (768:1)
options.factory
/_next/static/chunks/webpack.js (691:31)
__webpack_require__
file:/Users/vidit/GitHubProjects/squawk-components/.next/static/chunks/webpack.js (37:33)
fn
/_next/static/chunks/webpack.js (346:21)
<unknown>
node_modules/next/dist/build/webpack/loaders/next-client-pages-loader.js?absolutePagePath=%2FUsers%2Fvidit%2FGitHubProjects%2Fsquawk-components%2Fsrc%2Fpages%2Fuser%2F%5Busername%5D.jsx&page=%2Fuser%2F%5Busername%5D! (5:15)
execute
node_modules/next/dist/client/route-loader.js (211:50)

我使用 npm update --legacy-peer-deps 更新了所有安装的包

node.js next.js auth0 supabase
© www.soinside.com 2019 - 2024. All rights reserved.