Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on build next.js 13 app with analytics #161

Open
thigas88 opened this issue Nov 23, 2024 · 1 comment
Open

Error on build next.js 13 app with analytics #161

thigas88 opened this issue Nov 23, 2024 · 1 comment

Comments

@thigas88
Copy link

Next.js 13
Analytics 1.4.1

yarn run build
yarn run v1.22.22
$ next build

Get this error :

Collecting page data ..file:///node_modules/@vercel/analytics/dist/next/index.mjs:159
import { useParams, usePathname, useSearchParams } from "next/navigation.js";
         ^^^^^^^^^
SyntaxError: Named export 'useParams' not found. The requested module 'next/navigation.js' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'next/navigation.js';
const { useParams, usePathname, useSearchParams } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:146:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:229:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:473:24)
file:///Users/thiago/Projetos/deliveryfoody-web/node_modules/@vercel/analytics/dist/next/index.mjs:159
import { useParams, usePathname, useSearchParams } from "next/navigation.js";
@sajeebmahamed
Copy link

I resolved the issue by importing @vercel/analytics/react instead of @vercel/analytics/next

{
  "next": "13.0.7",
  "@vercel/analytics": "^1.4.1"
}

import { Analytics } from '@vercel/analytics/next';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants