TypeError: Cannot read property 'hash' of null
TypeError: Cannot read property 'hash' of null
我 运行 在进行一些更改后部署到 Vercel 时遇到问题。
运行 npm run dev
有效,但在部署到 Vercel(与 npm run build
一起运行)后,它会报错:
09:53:00.125 TypeError: Cannot read property 'hash' of null
09:53:00.125 at callback (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:59190:46)
09:53:00.125 at /vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:57683:39
09:53:00.125 at /vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:135587:5
09:53:00.125 at Hook.eval [as callAsync] (eval at create (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:33832:10), :6:1)
09:53:00.126 at AsyncQueue._handleResult (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:135557:21)
09:53:00.126 at /vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:135540:11
09:53:00.126 at /vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:59794:14
09:53:00.126 at /vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:59452:6
09:53:00.126 at done (/vercel/path0/node_modules/next/dist/compiled/neo-async/async.js:1:10308)
09:53:00.126 at /vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:59356:13
09:53:00.126 at /vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:135587:5
09:53:00.126 at Hook.eval [as callAsync] (eval at create (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:33832:10), :6:1)
09:53:00.127 at AsyncQueue._handleResult (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:135557:21)
09:53:00.127 at /vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:135540:11
09:53:00.127 at Array. (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:59296:4)
09:53:00.128 at runCallbacks (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:20480:15)
09:53:00.155 Error: Command "npm run build" exited with 1
抱歉,如果格式难以阅读,我不太确定如何在没有格式 运行.
的情况下复制错误日志
我所做的所有更改都可以归结为添加一个使用 NavBar, and Footer
组件的 Layout
组件。然后我修改了 _app.js
文件以使用所述布局:
import React from "react";
import App from "next/app";
import "tailwindcss/tailwind.css";
import Layout from "../components/Layout";
class MyApp extends App {
render() {
const { Component, pageProps, router } = this.props;
if (router.pathname.startsWith("/shop/")) { //router path check to include/exclude Layout e.g: paths starting with /shop
return (
<Layout>
<Component {...pageProps}></Component>
</Layout>
);
}
return <Component {...pageProps}></Component>;
}
}
export default MyApp;
非常感谢有关此错误的任何见解!
难道我们不导入 Component 吗,它是 react 模块的保留关键字,用于扩展 class
import React, { Component } from "react";
class SomeNavComponent extends Component {
此外,在我看来,问题似乎出在组件的命名上
const { Component, pageProps, router } = this.props;
没有改变任何东西,在再次推送到 Vercel 后错误没有弹出,所以我猜它现在“已修复”。
我 运行 在进行一些更改后部署到 Vercel 时遇到问题。
运行 npm run dev
有效,但在部署到 Vercel(与 npm run build
一起运行)后,它会报错:
09:53:00.125 TypeError: Cannot read property 'hash' of null 09:53:00.125 at callback (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:59190:46) 09:53:00.125 at /vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:57683:39 09:53:00.125 at /vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:135587:5 09:53:00.125 at Hook.eval [as callAsync] (eval at create (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:33832:10), :6:1) 09:53:00.126 at AsyncQueue._handleResult (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:135557:21) 09:53:00.126 at /vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:135540:11 09:53:00.126 at /vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:59794:14 09:53:00.126 at /vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:59452:6 09:53:00.126 at done (/vercel/path0/node_modules/next/dist/compiled/neo-async/async.js:1:10308) 09:53:00.126 at /vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:59356:13 09:53:00.126 at /vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:135587:5 09:53:00.126 at Hook.eval [as callAsync] (eval at create (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:33832:10), :6:1) 09:53:00.127 at AsyncQueue._handleResult (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:135557:21) 09:53:00.127 at /vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:135540:11 09:53:00.127 at Array. (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:59296:4) 09:53:00.128 at runCallbacks (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:20480:15) 09:53:00.155 Error: Command "npm run build" exited with 1
抱歉,如果格式难以阅读,我不太确定如何在没有格式 运行.
的情况下复制错误日志我所做的所有更改都可以归结为添加一个使用 NavBar, and Footer
组件的 Layout
组件。然后我修改了 _app.js
文件以使用所述布局:
import React from "react";
import App from "next/app";
import "tailwindcss/tailwind.css";
import Layout from "../components/Layout";
class MyApp extends App {
render() {
const { Component, pageProps, router } = this.props;
if (router.pathname.startsWith("/shop/")) { //router path check to include/exclude Layout e.g: paths starting with /shop
return (
<Layout>
<Component {...pageProps}></Component>
</Layout>
);
}
return <Component {...pageProps}></Component>;
}
}
export default MyApp;
非常感谢有关此错误的任何见解!
难道我们不导入 Component 吗,它是 react 模块的保留关键字,用于扩展 class
import React, { Component } from "react";
class SomeNavComponent extends Component {
此外,在我看来,问题似乎出在组件的命名上
const { Component, pageProps, router } = this.props;
没有改变任何东西,在再次推送到 Vercel 后错误没有弹出,所以我猜它现在“已修复”。