PiwikPRO / next-piwik-pro

Library for implementing Piwik PRO in Next.js web applications
MIT License
1 stars 6 forks source link

SyntaxError: Cannot use import statement outside a module #9

Closed ciruz closed 1 year ago

ciruz commented 1 year ago

I set up Piwik PRO with next.js, according to the following official instructions - https://developers.piwik.pro/en/latest/data_collection/web/frameworks/Piwik_PRO_Library_for_NextJS.html

But immediately when I start the dev server, I get this import error:

/Users/ciruz/dev/node/next-piwik/node_modules/@piwikpro/next-piwik-pro/index.js:1 import { PiwikProProvider, usePiwikPro } from './core'; ^^^^^^

SyntaxError: Cannot use import statement outside a module

I also created a new and blank next.js installation without any modifications, still get the same error.

Empty next example repo: https://github.com/ciruz/next-piwik-error

Any ideas? Thanks

ciruz commented 1 year ago

In the readme.md is a useful information about import errors with ESM libaries. This solved my issue. I added this information to the docs too.