vercel / analytics

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

@vercel/analytics throws errors #114

Closed samuelcole closed 9 months ago

samuelcole commented 9 months ago

I just upgraded to Next 14, and @vercel/analytics started throwing this error:

file:///var/task/node_modules/@vercel/analytics/dist/react/index.js:4
import { useEffect } from "react";
         ^^^^^^^^^
SyntaxError: Named export 'useEffect' not found. The requested module 'react' 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 'react';
const { useEffect } = pkg;

I'm still on the pages router if that makes a difference.

samuelcole commented 9 months ago

error just moves after removing @vercel/analytics, so it's a general next error

file:///var/task/node_modules/swr/_internal/dist/index.mjs:1
import React, { useEffect, useLayoutEffect, createContext, useContext, useMemo, useRef, createElement } from 'react';
                                            ^^^^^^^^^^^^^
SyntaxError: Named export 'createContext' not found. The requested module 'react' 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 'react';
const { useEffect, useLayoutEffect, createContext, useContext, useMemo, useRef, createElement } = pkg;
schnubor commented 9 months ago

Exact same experience here. Next14 and page router.

E: This seems related https://github.com/vercel/next.js/issues/57582

samuelcole commented 9 months ago

ah! thanks for the issue link @schnubor, i've been banging my head against it all day :-)

tobiaslins commented 9 months ago

Hey! Yes that seems to be related to https://github.com/vercel/next.js/issues/57582 as mentioned by @schnubor , thanks :) Will close this for now