-
Notifications
You must be signed in to change notification settings - Fork 27.8k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Cannot find module '@next/third-parties/google' when trying to import GoogleTagManager #58697
Comments
I have the same error. |
Although my editor highlights the error, it works as expected in development server, but build command fails locally and on vercel. |
I added the following in my tsconfig under paths, and its allowing me to build locally. Yet to test remote.
|
Had the same issue with this Use Now import the module GoogleTagManager and it lets you use it without any error in both local development and production. |
This is due to the typescript's module resolution strategy. In typescript 5.0 new option was introduced and has been the recommended way if we use bundler's, new create-next-app uses this by default update tsconfig.json to use |
That does indeed fix GTM but unfortunately breaks a different module import. Is this something package authors need to fix? |
I have |
We fixed it in v14.0.4-canary.40, please upragde! |
Still not working in 14.0.4. Caution Cannot find module '@next/third-parties/google' or its corresponding type declarations. |
added this to my tsconfig.json, under paths
and importing on layout.tsx
currently working on |
Yes, that's what I did. That helped. Thank you. |
i agree, tried without this tsconfig.json and didn't work. hope they'll fix it soon |
Hi there, i upgraded to v14.0.4-canary.40 and I'm still getting the same error |
Noting this is a of #58458 (closed) |
#58697 (comment) helped me with my static site. Thanks. |
Not fixed in 14.0.4
This works for me |
It helps me too (build as well), but I guess crutch. Good to wait for official solution. |
This works for me "@next/third-parties": "^14.0.4", |
As of the latest canary release, you no longer need the npm i @next/third-parties@14.0.5-canary.59 And then imports should work as expected: import { GoogleAnalytics } from "@next/third-parties/google"; Tested and working on |
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Link to the code that reproduces this issue
https://codesandbox.io/p/devbox/musing-solomon-f4tnqz?file=%2Fapp%2Flayout.tsx%3A8%2C11
To Reproduce
Cannot find module '@next/third-parties/google' or its corresponding type declarations.typescript(2307)
Current vs. Expected behavior
Expected: import work as intended in documentation https://nextjs.org/docs/app/building-your-application/optimizing/third-party-libraries#google-tag-manager
Current: import not working

Verify canary release
Provide environment information
Which area(s) are affected? (Select all that apply)
App Router
Additional context
Tested using next/canary, next v14 and nextv13, all with same problems.
after changing the import to
import { GoogleTagManager } from '@next/third-parties/dist/google'
, the error goes away but when building the application i got an error because there is no exported module in node_modules@next\third-parties\dist\google.package.json
Error message:
Failed to compile.
./src/app/layout.tsx
Module not found: Package path ./dist/google is not exported from package /tmp/build_6a78ac44/node_modules/@next/third-parties (see exports field in /tmp/build_6a78ac44/node_modules/@next/third-parties/package.json)
The text was updated successfully, but these errors were encountered: