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

No "exports" main defined in node_modules/@automapper/classes/package.json #587

Closed
2 of 9 tasks
gabrielkim13 opened this issue Jan 22, 2024 · 4 comments
Closed
2 of 9 tasks
Labels
bug Something isn't working

Comments

@gabrielkim13
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Describe the issue

Hi there, @nartc!

First of all, thank you for taking the time to merge pending PRs and releasing version 8.8.0 of automapper-ts!

Unfortunately, it seems that some of these changes have introduced a minor issue in the @automapper/classes package:

image

Turns out that "./" is not a valid key for package.json's exports option.

For me, this is an issue when using pkg to generate single-executable Node binaries, as I get the following error:

pkg/prelude/bootstrap.js:1872
      throw error;
      ^

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /snapshot/node_modules/@automapper/classes/package.json
    at exportsNotFound (node:internal/modules/esm/resolve:294:10)
    at packageExportsResolve (node:internal/modules/esm/resolve:641:9)
    at resolveExports (node:internal/modules/cjs/loader:591:36)
    at Module._findPath (node:internal/modules/cjs/loader:668:31)
    at Module._resolveFilename (node:internal/modules/cjs/loader:1130:27)
    at Function._resolveFilename (pkg/prelude/bootstrap.js:1947:44)
    at Module._load (node:internal/modules/cjs/loader:985:27)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at Module.require (pkg/prelude/bootstrap.js:1851:31)
    at require (node:internal/modules/helpers:176:18) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

Node.js v20.10.0

It seems to me that the fix is as simple as replacing "./" with just ".".

Models/DTOs/VMs

N/A

Mapping configuration

N/A

Steps to reproduce

Just open @automapper/classes on VSCode to get the aforementioned warning.

Expected behavior

The main export of @automapper/classes should be correctly identified when using pkg to generate single-executable Node binaries.

This is fixed by exporting ".", instead of "./", which is not a valid export path.

Screenshots

No response

Minimum reproduction code

No response

Package

  • I don't know.
  • @automapper/core
  • @automapper/classes
  • @automapper/nestjs
  • @automapper/pojos
  • @automapper/mikro
  • @automapper/sequelize
  • Other (see below)

Other package and its version

No response

AutoMapper version

8.8.0

Additional context

Linux Node v20

@gabrielkim13 gabrielkim13 added the bug Something isn't working label Jan 22, 2024
@timonmasberg
Copy link
Contributor

idk if its related, but jest also starts throwing errors:

        node_modules/@automapper/classes/src/index.d.ts:1
           ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){export * from './lib/classes';
                                                                                             ^^^^^^
       
           SyntaxError: Unexpected token 'export'
       
           > 1 | import { AutoMap } from '@automapper/classes';
               | ^

i tried different configs like adding the package to the transformIgnorePatterns or using jest with its esm configs, but i was not able to resolve the error on the new version.

@gabrielkim13
Copy link
Contributor Author

gabrielkim13 commented Jan 22, 2024

I'm not sure whether the jest error is related to this issue.

The change to @automapper/classes's package.json that causes the issue with pkg was made in a2dea1d (2023-03-10), while version 8.7.7 was released earlier (2022-10-25), so it's possible.

Someone else said that the error occurred in 8.7.7, but he/she removed the comment. Can you verify this @timonmasberg?

@timonmasberg
Copy link
Contributor

Someone else said that the error occurred in 8.7.7, but he/she removed the comment. Can you verify this @timonmasberg?

I can not reproduce the error on 8.7.7, its probably not related to this issue but rather to this change

@gabrielkim13
Copy link
Contributor Author

Solved with #589.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants