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

Unable to resolve path to module '@sentry/nestjs' #14789

Closed
3 tasks done
abriginets opened this issue Dec 18, 2024 · 4 comments
Closed
3 tasks done

Unable to resolve path to module '@sentry/nestjs' #14789

abriginets opened this issue Dec 18, 2024 · 4 comments
Assignees
Labels
Package: nestjs Issues related to the Sentry Nestjs SDK

Comments

@abriginets
Copy link

Is there an existing issue for this?

How do you use Sentry?

Self-hosted/on-premise

Which SDK are you using?

@sentry/nestjs

SDK Version

8.47.0

Framework Version

NestJS 10.3.7

Link to Sentry event

No response

Reproduction Example/SDK Setup

import * as Sentry from '@sentry/nestjs';
import dotenv from 'dotenv';

dotenv.config();

if (!process.env.SENTRY_DSN) {
  throw new Error('process.env.SENTRY_DSN is not defined');
}

if (!process.env.SENTRY_ENV) {
  throw new Error('process.env.SENTRY_ENV is not defined');
}

Sentry.init({
  dsn: process.env.SENTRY_DSN,
  sampleRate: 0.1,
  environment: process.env.SENTRY_ENV,
});

Steps to Reproduce

  1. Install @sentry/nestjs package
  2. Add eslint and eslint-import-plugin to your project (you may also just clone https://github.com/abriginets/nest-starter)
  3. Try importing something from @sentry/nestjs. You'll get eslint error

Unable to resolve path to module '@sentry/nestjs'. (eslint import/no-unresolved)

This occurs because of the bad path in package.json of @sentry/nestjs:

  "main": "build/cjs/nestjs/index.js",
  "module": "build/esm/nestjs/index.js",

If you look into filesystem, there won't be nestjs dir.

Image

I've been able to successfully patch this by creating nestjs directory under node_modules/@sentry/nestjs/build/cjs/ and by putting all the files from aforementioned directory into it.

Image

The error was gone after this.

Expected Result

Files location should correspond to what's declared in package.json

Actual Result

Files location and package.json declaration mismatch

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Dec 18, 2024
@github-actions github-actions bot added the Package: nestjs Issues related to the Sentry Nestjs SDK label Dec 18, 2024
@AbhiPrasad
Copy link
Member

yup this feels like a bug, especially considering we have it properly defined in the exports conditions. Will fix!

@AbhiPrasad AbhiPrasad self-assigned this Dec 18, 2024
AbhiPrasad added a commit that referenced this issue Dec 19, 2024
ref #14789

`build/cjs/nestjs/index.js` and `build/esm/nestjs/index.js` doesn't
exist, this fixes that.
@AbhiPrasad
Copy link
Member

We merged in #14791 - will make a release after we also merge in #14799

@AdityaZwing
Copy link

Image

In case you are still wondering what the issue was about.

@AbhiPrasad
Copy link
Member

it's end of year next week and most of sentry is on holiday. We'll do a release at the start of the new year!

In case you are still wondering what the issue was about.

Yup @AdityaZwing that was the thing we fixed, but it's also on the tooling given main/module has been effectively deprecated for exports field. eslint-plugin-import and similar tooling should really use exports instead of main/module

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

No branches or pull requests

3 participants