4

After adding Sentry.io with the automatic wizard (it added "@sentry/nextjs": "^6.11.0" in package.json), I can't build my Next.js project anymore.

> npm run build
(...)
Error: Command failed with exit code 1: node_modules/.bin/next build
warn  - No ESLint configuration detected. Run next lint to begin setup
Failed to compile.
ModuleNotFoundError: Module not found: Error: Can't resolve 'webpack' in '/builds/group/project/web/node_modules/@next/react-refresh-utils'
(...)
info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5

I tried to npm install --save-dev webpack but I'm running in other errors like

./node_modules/fsevents/fsevents.node
Module parse failed: Unexpected character '�' (1:0)

How can I fix this?

[EDIT] I also use Serverless component @sls-next/[email protected] to deploy on AWS. My next.config.js contains:

const moduleExports = { target: 'serverless' };
3
  • You could Tr deleting your node_modules folder and reinstalling dependencies, maybe something got mixed up Commented Aug 27, 2021 at 15:30
  • just tried but same error "Can't resolve 'webpack'" Commented Aug 27, 2021 at 15:55
  • Did it create or modify webpack, babel or ts configurations? Commented Aug 27, 2021 at 17:48

2 Answers 2

4

Found. The problem was due to conflict with Serverless framework.

As described in https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/ enter image description here

I just added useServerlessTraceTarget: true to serverless.yml:

project:
  component: "@sls-next/[email protected]"
  inputs:
    useServerlessTraceTarget: true
    (...)
Sign up to request clarification or add additional context in comments.

1 Comment

I am facing the same issue. Should I create a file called serverless.yml?
1

Check the next.config.js file in the project root folder.

According to this guide, some changes are needed there, and maybe the wizard got it wrong: https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/

Post the file contents here for more help if needed.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.