ModuleNotFoundError: Module not found: Error: Can't resolve 'pnpapi'
See original GitHub issue- Review the documentation: https://docs.sentry.io/
- Search for existing issues: https://github.com/getsentry/sentry-javascript/issues
- Use the latest release: https://github.com/getsentry/sentry-javascript/releases
- Provide a link to the affected event from your Sentry account
Package + Version
-
@sentry/browser
-
@sentry/node
-
raven-js
-
raven-node
(raven for node) - other:
Version:
"@sentry/nextjs": "6.4.1",
Description
When we include import * as Sentry from '@sentry/nextjs'
anywhere within the app - it throws this ModuleNotFoundError: Module not found: Error: Can't resolve 'pnpapi'
this error on build yarn run build
- FWIW - we are still on webpack4
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
module not found: Error: Can't resolve 'pnpapi' in '/app ...
Encountered this bug error when when I tried to build my next app. Build error occurred. Error: > Build failed because of webpack...
Read more >reactjs - module not found: Error: Can't resolve 'pnpapi' in '/app ...
This import appeared in my code, in the index of my application. I removed it and webpack was working again.
Read more >Can't resolve 'pnpapi' with webpack 5.4.0 - Rysolv
I'm still getting this error, but with yarn berry. Cannot find module 'pnpapi' from 'rootDir/.yarn/cache/enhanced-resolve-npm-5.9.2- ...
Read more >Next.js + Webpack - Fix for ModuleNotFoundError: Module not ...
To fix the error with Webpack 5, update your Next.js config file ( /next.config.js ) with the following, it tells webpack not to...
Read more >module-not-found - Next.js
A module not found error can occur for many different reasons: The module you're trying to import is not installed in your dependencies;...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@AbhiPrasad, Thanks for the solution, changing the target to
experimental-serverless-trace
works but if the project is deployed on Netlify failed while runningnetlify build
. Hoping to get some solution.Hey @followbl, thanks for the detailed config. It seems the issue is related to the
target: serverless
in your webpack config. It seems that Vercel folks prefer theexperimental-serverless-trace
target over theserverless
target. Vercel Now also usesexperimental-serverless-trace
now from what I see.See the PR adding experimental-serverless-trace to the nextjs repo for more details around this.
Could you try replacing the
serverless
target withexperimental-serverless-trace
and seeing if the build errors still occur? This fixes it on our end.If the
serverless
target is required for your setup, please let us know and we can continue investigating, but theexperimental-serverless-trace
target should cover all the use cases.