vercel / analytics

Privacy-friendly, real-time traffic insights
https://vercel.com/analytics
Mozilla Public License 2.0
422 stars 26 forks source link

Error: Cannot find module 'private-next-rsc-mod-ref-proxy' #82

Closed zhangela closed 1 year ago

zhangela commented 1 year ago

When following instructions (https://vercel.com/docs/concepts/analytics/quickstart) to add Vercel analytics, I'm getting this error:

error - Error: Cannot find module 'private-next-rsc-mod-ref-proxy'
Require stack:
- /Users/zhangela/projects/dispatch/website/.next/server/app/page.js
- /Users/zhangela/projects/dispatch/website/node_modules/next/dist/server/require.js
- /Users/zhangela/projects/dispatch/website/node_modules/next/dist/server/load-components.js
- /Users/zhangela/projects/dispatch/website/node_modules/next/dist/build/utils.js
- /Users/zhangela/projects/dispatch/website/node_modules/next/dist/server/dev/static-paths-worker.js
- /Users/zhangela/projects/dispatch/website/node_modules/next/dist/compiled/jest-worker/processChild.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
    at mod._resolveFilename (/Users/zhangela/projects/dispatch/website/node_modules/next/dist/build/webpack/require-hook.js:23:32)
    at Module._load (node:internal/modules/cjs/loader:841:27)
    at Module.require (node:internal/modules/cjs/loader:1061:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at eval (webpack-internal:///(sc_server)/./node_modules/@vercel/analytics/dist/react/index.js:2:74)
    at (sc_server)/./node_modules/@vercel/analytics/dist/react/index.js (/Users/zhangela/projects/dispatch/website/.next/server/app/page.js:2529:1)
    at __webpack_require__ (/Users/zhangela/projects/dispatch/website/.next/server/webpack-runtime.js:33:43)
    at eval (webpack-internal:///(sc_server)/./app/layout.tsx:8:81)
    at (sc_server)/./app/layout.tsx (/Users/zhangela/projects/dispatch/website/.next/server/app/page.js:665:1) {
  type: 'Error',
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/zhangela/projects/dispatch/website/.next/server/app/page.js',
    '/Users/zhangela/projects/dispatch/website/node_modules/next/dist/server/require.js',
    '/Users/zhangela/projects/dispatch/website/node_modules/next/dist/server/load-components.js',
    '/Users/zhangela/projects/dispatch/website/node_modules/next/dist/build/utils.js',
    '/Users/zhangela/projects/dispatch/website/node_modules/next/dist/server/dev/static-paths-worker.js',
    '/Users/zhangela/projects/dispatch/website/node_modules/next/dist/compiled/jest-worker/processChild.js'
  ],
  page: '/'
}

and this warning:

Attempted import error: 'Analytics' is not exported from '@vercel/analytics/react' (imported as 'Analytics').

Relevant package.json:

        "@vercel/analytics": "^1.0.1",
        "next": "13.0.8-canary.0",

layout.tsx:


import { Inter } from "@next/font/google";

import "../styles/globals.css";

const inter = Inter({
  subsets: ["latin"],
  variable: "--font-inter",
});

export default function DotComLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    <html lang="en" className={`${inter.variable} h-full scroll-smooth`}>
      <body>
        {children}
        <Analytics />
      </body>
    </html>
  );
}
zhangela commented 1 year ago

... fixed by updating to latest version of Next.js

BeaRRRRR commented 1 year ago

@zhangela Thank you, you saved me haha! Tried to get it working for a while, when the fix was just updating to the latest version