NextJS error on launch: Module not found: Can't resolve 'net'
See original GitHub issueIs there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which package are you using?
SDK Version
7.26.0
Framework Version
13.0.6
Link to Sentry event
No response
Steps to Reproduce
Update from ^7.21.1 to ^7.26.0 leads to an initialization error I did not have before.
I already have a webpack configuration which tell that NodeJS dependencies must not be resolved :
webpack: (config, { isServer }) => {
if (!isServer) {
config.resolve = {
...config.resolve,
fallback: {
// fixes proxy-agent dependencies
net: false,
dns: false,
tls: false,
assert: false,
// fixes sentry dependencies
process: false
}
};
}
return config;
},
sentry: {
hideSourceMaps: true
}
I cannot tell why this is happening.
Expected Result
Have no error on next command
Actual Result
error - ./node_modules/https-proxy-agent/dist/agent.js:15:0 Module not found: Can’t resolve ‘net’
Import trace for requested module: ./node_modules/https-proxy-agent/dist/index.js ./src/services/xx/xx.ts ./src/utils/xx/xx.ts ./src/utils/xx/xx.ts ./src/utils/xx/xx/Error.ts ./src/pages/_error.tsx
Issue Analytics
- State:
- Created 9 months ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
Error: Can't resolve 'net' in 'node_modules/stompjs/lib' - ...
The issue is caused by expecting the net package which is a package from Node.JS and does not exist in the browser. If...
Read more >module-not-found
The module you're trying to import is not installed in your dependencies · The module you're trying to import is in a different...
Read more >How To Solve Module Not Found Can't Resolve 'fs' in Next.js
This error seems straightforward: the filesystem module is not found. Maybe it was not installed or something like that. However, what made this ......
Read more >How to fix the `can't resolve module` error in Next.js
How to fix the `can't resolve module` error in Next.js ... In a Next.js page your can import methods from a file that...
Read more >next js module not found: can't resolve 'fs'
As shown in the resolve.fallback section of the Webpack documentation, the primary reason for this config option is because as-of Webpack v5.x, core...
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
I suggest looking at this thread where I go into a bit more detail: https://github.com/getsentry/sentry-javascript/issues/6339
TLDR: Plugins may return functions and you need to pass all args from the module.exports function to it OR you put the sentry plugin last like the docs suggest.
Finally works ! 😃 Thank you for the advice.
Can you please explain a little more what and why you modified ?