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

时间:2021-07-22 07:57:32

标签: next.js sentry

我更喜欢 https://docs.sentry.io/platforms/javascript/guides/nextjs 中的文档将 @sentry/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:\Users\DELL\Desktop\ws-or\fjob-frontend\.next' directory! Try building your app with 'next build' before starting the server.
    at Server.readBuildId (C:\Users\DELL\Desktop\ws-or\fjob-frontend\node_modules\next\dist\next-server\server\next-server.js:137:355)
    at new Server (C:\Users\DELL\Desktop\ws-or\fjob-frontend\node_modules\next\dist\next-server\server\next-server.js:3:120)
    at Function.createServer [as default] (C:\Users\DELL\Desktop\ws-or\fjob-frontend\node_modules\next\dist\server\next.js:2:638)
    at Object.instrumentServer (C:\Users\DELL\Desktop\ws-or\fjob-frontend\node_modules\@sentry\nextjs\dist\utils\instrumentServer.js:42:67)
    at Object.<anonymous> (C:\Users\DELL\Desktop\ws-or\fjob-frontend\node_modules\@sentry\nextjs\dist\index.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 的问题。如果我删除哨兵配置,我可以像往常一样启动我的服务器。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

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