将sentry添加到nextjs项目后无法运行服务器



我更喜欢https://docs.sentry.io/platforms/javascript/guides/nextjs将@ssentint/nextjs添加到我的项目中。然后我把他们的配置添加到我的next.config.js 中

const { withSentryConfig } = require('@sentry/nextjs');
// module.exports = withBundleAnalyzer(nextConfig)
module.exports = {
}
const moduleExports = module.exports
const SentryWebpackPluginOptions = {
// Additional config options for the Sentry Webpack plugin. Keep in mind that
// the following options are set automatically, and overriding them is not
// recommended:
//   release, url, org, project, authToken, configFile, stripPrefix,
//   urlPrefix, include, ignore
silent: true, // Suppresses all logs
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options.
};
// Make sure adding Sentry options is the last code to run before exporting, to
// ensure that your source maps include changes from all other Webpack plugins
module.exports = withSentryConfig(moduleExports, SentryWebpackPluginOptions);

在我通过yarn dev运行服务器并得到这个错误之前,一切似乎都很好

Error: Could not find a valid build in the 'C:UsersDELLDesktopws-orfjob-frontend.next' directory! Try building your app with 'next build' before starting the server.
at Server.readBuildId (C:UsersDELLDesktopws-orfjob-frontendnode_modulesnextdistnext-serverservernext-server.js:137:355)
at new Server (C:UsersDELLDesktopws-orfjob-frontendnode_modulesnextdistnext-serverservernext-server.js:3:120)
at Function.createServer [as default] (C:UsersDELLDesktopws-orfjob-frontendnode_modulesnextdistservernext.js:2:638)
at Object.instrumentServer (C:UsersDELLDesktopws-orfjob-frontendnode_modules@sentrynextjsdistutilsinstrumentServer.js:42:67)
at Object.<anonymous> (C:UsersDELLDesktopws-orfjob-frontendnode_modules@sentrynextjsdistindex.server.js:56:20)
at Module._compile (internal/modules/cjs/loader.js:1068:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:933:32)
at Function.Module._load (internal/modules/cjs/loader.js:774:14)
at Module.require (internal/modules/cjs/loader.js:957:19)
(node:4084) Warning: Accessing non-existent property 'default' of module exports inside circular dependency     
(Use `node --trace-warnings ...` to show where the warning was created)
(node:4084) Warning: Accessing non-existent property 'target' of module exports inside circular dependency      
(node:4084) Warning: Accessing non-existent property 'amp' of module exports inside circular dependency
(node:4084) Warning: Accessing non-existent property 'experimental' of module exports inside circular dependency
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

经过几天的研究,我无法解决这个错误。我的nextjs配置是空的,我不认为这是next的问题。如果我删除哨兵配置,我可以像正常情况一样启动服务器。知道吗?

这个问题的解决方案是,将next.js升级到>=10.0.8 github.com/getsentry/sentry-javascript/issues/3274

将Next.js版本升级至适用于我的的最新版本

运行以升级到最新版本

npm install next@latest or yarn add next@latest

查看此处了解更多信息

对我起作用的是从我的.gitignore文件中删除.sentryclirc。它是由哨兵自动添加的,因此没有添加到构建中。(以防帮助他人(

相关内容

最新更新