Skip to content

Commit aaaedbc

Browse files
s1gr1dandreiborza
andauthored
docs(nuxt): Add readme docs for server-side setup (ESM) (#13019)
Specify how Nuxt is set up on the server-side. Nuxt v3+ runs with ESM. --------- Co-authored-by: Andrei <168741329+andreiborza@users.noreply.github.com>
1 parent 4bdd979 commit aaaedbc

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

packages/nuxt/README.md

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -102,21 +102,6 @@ Sentry.init({
102102

103103
### 4. Server-side setup
104104

105-
Add a `sentry.server.config.(js|ts)` file to the root of your project:
106-
107-
```javascript
108-
import * as Sentry from '@sentry/nuxt';
109-
110-
Sentry.init({
111-
dsn: process.env.DSN,
112-
});
113-
```
114-
115-
**Alternative Setup (ESM-compatible)**
116-
117-
This setup makes sure Sentry is imported on the server before any other imports. As of now, this however leads to an
118-
import-in-the-middle error ([related reproduction](https://github.com/getsentry/sentry-javascript-examples/pull/38)).
119-
120105
Add an `instrument.server.mjs` file to your `public` folder:
121106

122107
```javascript
@@ -130,7 +115,8 @@ if (process.env.SENTRY_DSN) {
130115
}
131116
```
132117

133-
Add an import flag to the node options, so the file loads before any other imports:
118+
Add an import flag to the `NODE_OPTIONS` of your preview script in the `package.json` file, so the file loads before any
119+
other imports:
134120

135121
```json
136122
{
@@ -140,6 +126,18 @@ Add an import flag to the node options, so the file loads before any other impor
140126
}
141127
```
142128

129+
If you are getting an `import-in-the-middle` error message, add the package with a minimum version of `1.10.0` as a
130+
dependency to your `package.json`
131+
([issue reference](https://github.com/getsentry/sentry-javascript-examples/pull/38#issuecomment-2245259327)):
132+
133+
```json
134+
{
135+
"dependencies": {
136+
"import-in-the-middle": "1.10.0"
137+
}
138+
}
139+
```
140+
143141
### 5. Vite Setup
144142

145143
todo: add vite setup

0 commit comments

Comments
 (0)