webtorrent/parse-torrent

ERR_PACKAGE_PATH_NOT_EXPORTED when importing this package in fastify

johann-taberlet opened this issue ยท 6 comments

What version of this package are you using?
10.0.0

What operating system, Node.js, and npm version?
MacOS Ventura 13.0.1 M1 Pro Chip
Tried on both Node.js v 18.12.1 and 14.21.1
pnpm 7.17.1

What happened?
When I symply import the package with import parseTorrent from "parse-torrent"; I got his error:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /Users/johann/Dev/perso/netflux/backend/node_modules/parse-torrent/package.json
    at new NodeError (internal/errors.js:322:7)
    at throwExportsNotFound (internal/modules/esm/resolve.js:332:9)
    at packageExportsResolve (internal/modules/esm/resolve.js:523:7)
    at resolveExports (internal/modules/cjs/loader.js:450:36)
    at Function.Module._findPath (internal/modules/cjs/loader.js:490:31)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:888:27)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:101:18)
    at Object.<anonymous> (/Users/johann/Dev/perso/netflux/backend/src/app.ts:3:1)
[ERROR] 16:24:27 Error: No "exports" main defined in /Users/johann/Dev/perso/netflux/backend/node_modules/parse-torrent/package.json

What did you expect to happen?
Being able to import this package in an ES6 env

Are you willing to submit a pull request to fix this bug?
Not sure what's going on so sadly, no.

Edit: Backed to 9.1.5 and everything works fine

image

import parseTorrent, { remote } from 'parse-torrent'

console.log(parseTorrent, remote)

can't reproduce, try running npm update

Same error for me on a TypeScript project, tried to import with a :

import parseTorrent from 'parse-torrent';

but got error :

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /path/to/project/node_modules/parse-torrent/package.json
    at new NodeError (node:internal/errors:393:5)
    at throwExportsNotFound (node:internal/modules/esm/resolve:358:9)
    at packageExportsResolve (node:internal/modules/esm/resolve:612:7)
    at resolveExports (node:internal/modules/cjs/loader:529:36)
    at Function.Module._findPath (node:internal/modules/cjs/loader:569:31)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:981:27)
    at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] (/path/to/project/node_modules/@cspotcode/source-map-support/source-map-support.js:811:30)
    at Function.Module._load (node:internal/modules/cjs/loader:841:27)
    at Module.require (node:internal/modules/cjs/loader:1061:19)
    at require (node:internal/modules/cjs/helpers:103:18) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

I have to revert to 9.x release to avoid error.

T00rk commented

Same problem

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /app/node_modules/parse-torrent/package.json
    at new NodeError (node:internal/errors:399:5)
    at exportsNotFound (node:internal/modules/esm/resolve:361:10)
    at packageExportsResolve (node:internal/modules/esm/resolve:641:13)
    at resolveExports (node:internal/modules/cjs/loader:565:36)
    at Module._findPath (node:internal/modules/cjs/loader:634:31)
    at Module._resolveFilename (node:internal/modules/cjs/loader:1061:27)
    at Module._load (node:internal/modules/cjs/loader:920:27)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (/app/lib/app.js:37:35) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

It seems you need to add "main": "index.js"in package.json

Same error here with version 11.0.12

same error on the last version of parse-torrent v11.0.12

Any news on this?