我正在将 Sentry 用于我现有的 Nextjs (14.0.4) 项目 在开发模式下没问题,但是当我运行命令 npm run build 时 它失败了
我提供终端错误和sentry.client.config.js和next.config.js文件 当我运行 npm start 时,下面我提供了终端错误
终端错误
// terminal
[@sentry/nextjs] The Sentry Next.js SDK `tunnelRoute` option will not work in combination with Next.js static exports. The `tunnelRoute` option uses serverside features that cannot be accessed in export mode. If you still want to tunnel Sentry events, set up your own tunnel: https://docs.sentry.io/platforms/javascript/troubleshooting/#using-the-tunnel-option
▲ Next.js 14.0.4
(node:11040) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Failed to compile.
Sentry CLI Plugin: Command failed: C:\Users\Sp\Desktop\app\tadvin_front\node_modules\@sentry\cli\sentry-cli.exe releases new tOJsUStMR7bNw0ClAehP6
Sentry CLI Plugin: Command failed: C:\Users\Sp\Desktop\app\tadvin_front\node_modules\@sentry\cli\sentry-cli.exe releases new tOJsUStMR7bNw0ClAehP6
> Build failed because of webpack errors
Creating an optimized production build .
sentry.client.config.js 文件
//sentry.client.config.js
import * as Sentry from "@sentry/nextjs";
Sentry.init({
dsn: "https://[email protected]/6403",
tracesSampleRate: 1,
debug: true,
replaysOnErrorSampleRate: 1.0,
replaysSessionSampleRate: 0.1,
integrations: [
Sentry.replayIntegration({
maskAllText: true,
blockAllMedia: true,
}),
],
});
next.config.js 文件
//next.config.js
const { withSentryConfig } = require("@sentry/nextjs");
const nextConfig = {
output : 'export',
reactStrictMode: false,
swcMinify: true,
trailingSlash: true,
images: {
remotePatterns: [
{
protocol: "https",
hostname: "185.243.48.21/",
pathname: "/**",
},
],
unoptimized: true,
},
eslint: {
ignoreDuringBuilds: true,
},
};
module.exports = withSentryConfig(
nextConfig,
{
silent: true,
org: "pettino",
project: "tadvin_front",
url: "https://sentry.hamravesh.com/"
},
{
widenClientFileUpload: true,
transpileClientSDK: true,
tunnelRoute: "/monitoring",
hideSourceMaps: true,
disableLogger: true,
automaticVercelMonitors: true,
}
);
当我运行 npm start 时
终端错误是
[@sentry/nextjs] The Sentry Next.js SDK `tunnelRoute` option will not work in combination with Next.js static exports. The `tunnelRoute` option uses serverside features that cannot be accessed in export mode. If you still want to tunnel Sentry events, set up your own tunnel: https://docs.sentry.io/platforms/javascript/troubleshooting/#using-the-tunnel-option
[Error: ENOENT: no such file or directory, open 'C:\Users\Sp\Desktop\app\tadvin_front\.next\BUILD_ID'] {
errno: -4058,
code: 'ENOENT',
syscall: 'open',
path: 'C:\\Users\\Sp\\Desktop\\app\\tadvin_front\\.next\\BUILD_ID'
}
https://github.com/getsentry/sentry-javascript/issues
您可以在这里创建一个包含更多信息的问题吗?我之前遇到过一个问题,我相信这可能与开发模式下涡轮机组的使用有关