Failed to build Astro site while using @cloudflare/pages-plugin-sentry

Trying to integrate sentry plugin for cloudflare with astro and it is failing to build. The setup is like this
// middleware.ts
import sentryPlugin from '@cloudflare/pages-plugin-sentry';

export const onRequest = sentryPlugin({
dsn: 'sentry-dns',
});
// middleware.ts
import sentryPlugin from '@cloudflare/pages-plugin-sentry';

export const onRequest = sentryPlugin({
dsn: 'sentry-dns',
});
// astro.config.ts
{
output: 'hybrid',
experimental: {
hybridOutput: true,
middleware: true,
},
adapter: cloudflare({ mode: 'directory' }),
}
// astro.config.ts
{
output: 'hybrid',
experimental: {
hybridOutput: true,
middleware: true,
},
adapter: cloudflare({ mode: 'directory' }),
}
The error that I am getting it with the sentry package
prerendering static routes
(node:48390) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/Users/akash/Documents/personal/akashrajpurohit.com/node_modules/.pnpm/@[email protected]/node_modules/@cloudflare/pages-plugin-sentry/index.js:3344
export {
^^^^^^

SyntaxError: Unexpected token 'export'
at internalCompileFunction (node:internal/vm:73:18)
at wrapSafe (node:internal/modules/cjs/loader:1176:20)
at Module._compile (node:internal/modules/cjs/loader:1218:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Module._load (node:internal/modules/cjs/loader:958:12)
at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:169:29)
at ModuleJob.run (node:internal/modules/esm/module_job:194:25) {
plugin: undefined,
hint: undefined
}

Node.js v18.16.0
 ELIFECYCLE  Command failed with exit code 1.
prerendering static routes
(node:48390) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/Users/akash/Documents/personal/akashrajpurohit.com/node_modules/.pnpm/@[email protected]/node_modules/@cloudflare/pages-plugin-sentry/index.js:3344
export {
^^^^^^

SyntaxError: Unexpected token 'export'
at internalCompileFunction (node:internal/vm:73:18)
at wrapSafe (node:internal/modules/cjs/loader:1176:20)
at Module._compile (node:internal/modules/cjs/loader:1218:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Module._load (node:internal/modules/cjs/loader:958:12)
at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:169:29)
at ModuleJob.run (node:internal/modules/esm/module_job:194:25) {
plugin: undefined,
hint: undefined
}

Node.js v18.16.0
 ELIFECYCLE  Command failed with exit code 1.
Package versions:
"astro": "^2.5.7",
"@astrojs/cloudflare": "^6.3.0",
"@cloudflare/pages-plugin-sentry": "^1.1.1",
"astro": "^2.5.7",
"@astrojs/cloudflare": "^6.3.0",
"@cloudflare/pages-plugin-sentry": "^1.1.1",
3 Replies
Walshy
Walshy2y ago
(node:48390) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
Make sure you have "type": "module" in your package.json
Akash Rajpurohit
Akash RajpurohitOP2y ago
I have that for the astro project, I think it is complaining about it from the sentry package?
Akash Rajpurohit
Akash RajpurohitOP2y ago
Verified that the @cloudflare/pages-plugin-sentry is missing the type=module. For now to unblock myself and for someone else who might be facing this issue, I am directly using the https://www.npmjs.com/package/toucan-js package which is used internally by this package directly.
npm
toucan-js
Cloudflare Workers client for Sentry. Latest version: 3.1.0, last published: 5 months ago. Start using toucan-js in your project by running npm i toucan-js. There are 16 other projects in the npm registry using toucan-js.
Want results from more Discord servers?
Add your server