axiomhq / next-axiom

The official Next.js library for Axiom.
https://axiom.co/vercel
MIT License
357 stars 27 forks source link

Module not found: Can't resolve 'whatwg-fetch' #224

Closed Lantianyou closed 2 weeks ago

Lantianyou commented 1 month ago

I constantly seeing this following warning in my local development environment

Module not found: Can't resolve 'whatwg-fetch' in '/Users/lantianyou/Developer/llamagen.ai/node_modules/next-axiom/dist'

Import trace for requested module:
./node_modules/next-axiom/dist/logger.js
./node_modules/next-axiom/dist/index.js
erehwonmi commented 1 month ago

Same issue. The library successfully transports the logs into Axiom, the only problem is the warning.

jessethomson commented 4 weeks ago

Everything works fine in 1.3.0, but this issue apprears in 1.4.0.

It looks like it was caused by this change #220 , which moved whatwg-fetch from the dependencies to the devDependencies in the package.json.

Unfortunately, whatwg-fetch is still being used as a dependency in the source code here, so that package needs to be moved back to a dependency in package.json.

Lantianyou commented 4 weeks ago

Agree

SollyzDev commented 4 weeks ago

hey, I will push a fix, but just wondering what is the env/runtime you are seeing this error with? the whatwg-fetch is used when fetch is not defined, perhaps old nodejs version?

SollyzDev commented 4 weeks ago

I have published a new path release, update to v1.4.1 and try again.

ventsislavnikolov commented 4 weeks ago

Hi, I had the same problem with 1.4.0: `⚠ ./node_modules/.pnpm/next-axiom@1.4.0next@15.0.0-rc.0@babel+core@7.25.2_@opentelemetry+api@1.9.0_react-dom@19.0._p5ajqxp6rwrezesmarsgnstbey/node_modules/next-axiom/dist/logger.js Module not found: Can't resolve 'whatwg-fetch' in '/Users/v.nikolov/Desktop/ventsislavnikolov/omnibodyhealthcare/node_modules/.pnpm/next-axiom@1.4.0next@15.0.0-rc.0@babel+core@7.25.2_@opentelemetry+api@1.9.0_react-dom@19.0._p5ajqxp6rwrezesmarsgnstbey/node_modules/next-axiom/dist'

Import trace for requested module: ./node_modules/.pnpm/next-axiom@1.4.0next@15.0.0-rc.0@babel+core@7.25.2_@opentelemetry+api@1.9.0_react-dom@19.0._p5ajqxp6rwrezesmarsgnstbey/node_modules/next-axiom/dist/logger.js ./node_modules/.pnpm/next-axiom@1.4.0next@15.0.0-rc.0@babel+core@7.25.2_@opentelemetry+api@1.9.0_react-dom@19.0._p5ajqxp6rwrezesmarsgnstbey/node_modules/next-axiom/dist/index.js ./src/app/global-error.tsx GET / 200 in 6709ms ⚠ ./node_modules/.pnpm/next-axiom@1.4.0next@15.0.0-rc.0@babel+core@7.25.2_@opentelemetry+api@1.9.0_react-dom@19.0._p5ajqxp6rwrezesmarsgnstbey/node_modules/next-axiom/dist/logger.js Module not found: Can't resolve 'whatwg-fetch' in '/Users/v.nikolov/Desktop/ventsislavnikolov/omnibodyhealthcare/node_modules/.pnpm/next-axiom@1.4.0next@15.0.0-rc.0@babel+core@7.25.2_@opentelemetry+api@1.9.0_react-dom@19.0._p5ajqxp6rwrezesmarsgnstbey/node_modules/next-axiom/dist'

Import trace for requested module: ./node_modules/.pnpm/next-axiom@1.4.0next@15.0.0-rc.0@babel+core@7.25.2_@opentelemetry+api@1.9.0_react-dom@19.0._p5ajqxp6rwrezesmarsgnstbey/node_modules/next-axiom/dist/logger.js ./node_modules/.pnpm/next-axiom@1.4.0next@15.0.0-rc.0@babel+core@7.25.2_@opentelemetry+api@1.9.0_react-dom@19.0._p5ajqxp6rwrezesmarsgnstbey/node_modules/next-axiom/dist/index.js ./src/app/global-error.tsx`

NodeJS: v22.5.1 PNPM: 9.6.0 NODE_ENV=development Runing on MacOS Sonoma v14.5

Note (major dependencies I use):

"next": "15.0.0-rc.0", "react": "19.0.0-rc-f994737d14-20240522", "react-dom": "19.0.0-rc-f994737d14-20240522",

With v1.4.1 I can confirm the problem is solved on my end.

erehwonmi commented 3 weeks ago

1.4.1 also fixed the issue for me. Thank you all.