sentry-javascript: NextJS error on launch: Module not found: Can't resolve 'net'
Is 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
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 16 (6 by maintainers)
This usually happens when you forget to add ‘use server’ on a server action file. Happened to me couple of times 👍 . Not really an issue, but on nextjs side the error message can be better.
Thanks @dragos199993
This should be higher. For visibility:
This usually happens when you forget to add
'use server'on a server action file.@dragos199993 Thanks, man. It’s been 20 minutes searching for what the issue is, and it turns out I forgot to add ‘use server’
On my end, the error was due to the import in client-side code of a server-side package ! Be careful with client / server-side imports mismatch and it might do the trick as it did for me.
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 ?
nextjs-i18n.config.js
next-redirects.config.js