Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot build Nuxt project: Cannot find package '@sentry-internal/nitro-utils' #14671

Open
3 tasks done
ffdevelit opened this issue Dec 11, 2024 · 7 comments
Open
3 tasks done
Labels
Package: nuxt Issues related to the Sentry Nuxt SDK

Comments

@ffdevelit
Copy link

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nuxt

SDK Version

8.43.0

Framework Version

Nuxt 3.14.1592

Link to Sentry event

No response

Reproduction Example/SDK Setup

We're trying to deploy an app on Cloudflare Pages and Vercel. However, we are unable to get though the build step, local fails as well.

Project config

nuxt.config.ts

modules: [
    '@sentry/nuxt/module',
]

sourcemap: {
    server: true,
    client: true,
},

sentry: {
    sourceMapsUploadOptions: {
      sourcemaps: {
        filesToDeleteAfterUpload: ['.*/**/*.map'],
      },
    },
},

nitro: {
    preset: 'cloudflare_pages',
    rollupConfig: {
      output: {
        sourcemap: 'hidden',
      },
    },
  },

runtimeConfig: {
public: {
      sentry: {
        dsn: '',
        environment: '',
      },
    },
}

sentry.client.config.ts

import * as Sentry from '@sentry/nuxt'

Sentry.init({
  dsn: useRuntimeConfig().public.sentry.dsn,
  environment: useRuntimeConfig().public.sentry.environment,
  tracesSampleRate: 1.0,
})

sentry.server.config.ts

import * as Sentry from '@sentry/nuxt'
import dotenv from '@dotenvx/dotenvx'

dotenv.config()

Sentry.init({
  dsn: process.env.NUXT_PUBLIC_SENTRY_DSN,
  environment: process.env.NUXT_PUBLIC_SENTRY_ENVIRONMENT,
  tracesSampleRate: 1.0,
})

Steps to Reproduce

We are unable to reproduce this issue on an isolated project, however the issue happens on a multiple projects of ours. What troubleshooting should we do to provide more information?

Expected Result

The project is built and deployed.

Actual Result

Cloudflare Pages:

17:49:57.540 | [error] [sentry-rollup-plugin] Info: Successfully uploaded source maps to Sentry
17:49:57.561 | [error] Cannot find package '@sentry-internal/nitro-utils' imported from /opt/buildhome/repo/node_modules/.cache/nuxt/.nuxt/prerender/index.mjs
17:49:57.561 | at new NodeError (node:internal/errors:405:5)
17:49:57.561 | at packageResolve (node:internal/modules/esm/resolve:887:9)
17:49:57.561 | at moduleResolve (node:internal/modules/esm/resolve:936:20)
17:49:57.561 | at defaultResolve (node:internal/modules/esm/resolve:1129:11)
17:49:57.561 | at nextResolve (node:internal/modules/esm/loader:163:28)
17:49:57.561 | at ESMLoader.resolve (node:internal/modules/esm/loader:835:30)
17:49:57.562 | at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
17:49:57.562 | at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:77:40)
17:49:57.562 | at link (node:internal/modules/esm/module_job:76:36)
17:49:57.562 |  
17:49:57.562 | [error] Cannot find package '@sentry-internal/nitro-utils' imported from /opt/buildhome/repo/node_modules/.cache/nuxt/.nuxt/prerender/index.mjs
17:49:57.664 | Failed: Error while executing user command. Exited with error code: 1
17:49:57.674 | Failed: build command exited with code: 1
17:49:59.013 | Failed: error occurred while running build comma
@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Dec 11, 2024
@github-actions github-actions bot added the Package: nuxt Issues related to the Sentry Nuxt SDK label Dec 11, 2024
@tongesy
Copy link

tongesy commented Dec 12, 2024

I'm having a similar issue with the build failing, with the following error:

[8:31:37 AM]  ERROR  [worker reload] [worker init] Cannot find package '@sentry-internal/nitro-utils' imported from /******/.nuxt/dev/index.mjs

  at packageResolve (node:internal/modules/esm/resolve:854:9)
  at moduleResolve (node:internal/modules/esm/resolve:927:18)
  at defaultResolve (node:internal/modules/esm/resolve:1169:11)
  at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:542:12)
  at ModuleLoader.resolve (node:internal/modules/esm/loader:510:25)
  at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:239:38)
  at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:96:40)
  at link (node:internal/modules/esm/module_job:95:36)

@sentry/[email protected]
[email protected]

running nuxt dev locally

@tongesy
Copy link

tongesy commented Dec 12, 2024

Downgrading to @sentry/[email protected] fixed the issue and allowed my build to succeed.

@ffdevelit
Copy link
Author

@tongesy Thanks for the input. Downgrading to @sentry/[email protected] did not solve the problem on our side.

@andreiborza
Copy link
Member

andreiborza commented Dec 12, 2024

Hi, this is something we overlooked sorry. We just released 8.44.0, please upgrade.

@thijsw
Copy link

thijsw commented Dec 12, 2024

After upgrading to version 8.44.0, I'm still getting the error when trying to run a production build

node .output/server/index.mjs
node:internal/modules/esm/resolve:839
  throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base), null);
        ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@sentry-internal/nitro-utils' imported from /Users/.../.output/server/index.mjs
    at packageResolve (node:internal/modules/esm/resolve:839:9)
    at moduleResolve (node:internal/modules/esm/resolve:908:18)
    at defaultResolve (node:internal/modules/esm/resolve:1038:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:554:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:523:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
    at ModuleJob._link (node:internal/modules/esm/module_job:126:49) {
  code: 'ERR_MODULE_NOT_FOUND'
}

Node.js v22.8.0

@ffdevelit
Copy link
Author

ffdevelit commented Dec 12, 2024

I confirm updating to @sentry/[email protected] did not solve the problem for us neither.

@andreiborza andreiborza reopened this Dec 12, 2024
@andreiborza
Copy link
Member

Thanks for confirming. We're looking into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: nuxt Issues related to the Sentry Nuxt SDK
Projects
Archived in project
Development

No branches or pull requests

5 participants