Skip to content

Commit 887b408

Browse files
authored
docs(nextjs): Add troubleshooting section for nx (#12090)
1 parent b195a9b commit 887b408

File tree

1 file changed

+41
-11
lines changed
  • docs/platforms/javascript/common/troubleshooting

1 file changed

+41
-11
lines changed

docs/platforms/javascript/common/troubleshooting/index.mdx

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -437,22 +437,22 @@ Learn more about fixing these caching issues in the <PlatformLink to="/sourcemap
437437
<PlatformSection notSupported={['javascript.nuxt']}>
438438
<Expandable permalink title="pnpm: Resolving 'import-in-the-middle' external package errors">
439439
440-
When using pnpm, you might encounter errors related to packages that can't be external, particularly with packages like `import-in-the-middle` and `require-in-the-middle`. These errors typically occur due to pnpm's strict dependency management and hoisting behavior.
440+
When using pnpm, you might encounter errors related to packages that can't be external, particularly with packages like `import-in-the-middle` and `require-in-the-middle`. These errors typically occur due to pnpm's strict dependency management and hoisting behavior.
441441
442-
While adding these packages as direct dependencies might remove the warning messages, it often doesn't resolve the underlying functionality issues:
442+
While adding these packages as direct dependencies might remove the warning messages, it often doesn't resolve the underlying functionality issues:
443443
444-
```bash
445-
pnpm add import-in-the-middle require-in-the-middle
446-
```
444+
```bash
445+
pnpm add import-in-the-middle require-in-the-middle
446+
```
447447
448-
As a workaround, create or modify `.npmrc` in your project root:
448+
As a workaround, create or modify `.npmrc` in your project root:
449449
450-
```npmrc
451-
shamefully-hoist=true
452-
```
453-
<Alert level="warning">
450+
```npmrc
451+
shamefully-hoist=true
452+
```
453+
<Alert level="warning">
454454
**Note**: While `shamefully-hoist=true` usually isn't the ideal solution from a dependency management perspective, it's sometimes necessary for compatibility with certain packages that expect Node.js module resolution behavior similar to npm or yarn.
455-
</Alert>
455+
</Alert>
456456
457457
458458
</Expandable>
@@ -540,4 +540,34 @@ Learn more about fixing these caching issues in the <PlatformLink to="/sourcemap
540540
</Expandable>
541541
</PlatformSection>
542542
543+
<PlatformSection supported={['javascript.nextjs']}>
544+
<Expandable permalink title="Using the Sentry Next SDK in a Nx monorepo (using `@nx/next`)">
545+
To set up Sentry's Next.js SDK in an Nx monorepo context, consider the following setup:
546+
547+
```js {filename:next.config.js}
548+
const nextConfig = {
549+
// ...
550+
};
551+
552+
const plugins = [
553+
// Your plugins excluding withNx
554+
];
555+
556+
module.exports = async (phase, context) => {
557+
let updatedConfig = plugins.reduce((acc, fn) => fn(acc), nextConfig);
558+
559+
// Apply the async function that `withNx` returns.
560+
updatedConfig = await withNx(updatedConfig)(phase, context);
561+
562+
return updatedConfig;
563+
};
564+
565+
// The Sentry plugin should always be applied last
566+
const { withSentryConfig } = require('@sentry/nextjs');
567+
module.exports = withSentryConfig(module.exports)
568+
```
569+
570+
</Expandable>
571+
</PlatformSection>
572+
543573
If you need additional help, you can [ask on GitHub](https://github.com/getsentry/sentry-javascript/issues/new/choose). Customers on a paid plan may also contact support.

0 commit comments

Comments
 (0)