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

Get an Error About export #2547

Closed
cuobiezi opened this issue May 23, 2022 · 12 comments
Closed

Get an Error About export #2547

cuobiezi opened this issue May 23, 2022 · 12 comments

Comments

@cuobiezi
Copy link

cuobiezi commented May 23, 2022

The Error is
× ERROR: Package subpath './lib/utils' is not defined by "exports" in D:\Jenkins\workspace\app\node_modules\cheerio\package.json

@fb55
Copy link
Member

fb55 commented May 23, 2022

Seems like you are using a deep import of lib/utils. Could you provide some context on what you are trying to accomplish? With that, lib/utils can be added as an exported file.

@RossMcMillan92
Copy link

Getting this too:

    Cannot find module 'cheerio/lib/utils' from 'node_modules/enzyme/build/Utils.js'

    Require stack:
      node_modules/enzyme/build/Utils.js
      node_modules/enzyme/build/ShallowWrapper.js
      node_modules/enzyme-to-json/utils.js
      node_modules/enzyme-to-json/createSerializer.js
      node_modules/enzyme-to-json/serializer.js

      at Resolver._throwModNotFoundError (node_modules/jest-resolve/build/resolver.js:491:11)
      at Object.<anonymous> (node_modules/enzyme/src/Utils.js:10:1)

@eahenke
Copy link

eahenke commented May 23, 2022

Seems like you are using a deep import of lib/utils. Could you provide some context on what you are trying to accomplish? With that, lib/utils can be added as an exported file.

Enzyme uses a deep import lib/utils (https://github.com/enzymejs/enzyme/blob/master/packages/enzyme/src/Utils.js#L11), so Enzyme and libraries built on Enzyme are failing due to this.
See: enzymejs/enzyme#2558 and enzymejs/enzyme#2559

The second Enzyme issue seems to imply that no immediate fix is coming from Enzyme to correct their import, so it may be easier and faster to add lib/utils as an exported file in Cheerio to make Enzyme's import valid.

@cuobiezi
Copy link
Author

Seems like you are using a deep import of lib/utils. Could you provide some context on what you are trying to accomplish? With that, lib/utils can be added as an exported file.

My error should be enzyme too

@cuobiezi
Copy link
Author

Seems like you are using a deep import of lib/utils. Could you provide some context on what you are trying to accomplish? With that, lib/utils can be added as an exported file.

Enzyme uses a deep import lib/utils (https://github.com/enzymejs/enzyme/blob/master/packages/enzyme/src/Utils.js#L11), so Enzyme and libraries built on Enzyme are failing due to this.

See: enzymejs/enzyme#2558 and enzymejs/enzyme#2559

The second Enzyme issue seems to imply that no immediate fix is coming from Enzyme to correct their import, so it may be easier and faster to add lib/utils as an exported file in Cheerio to make Enzyme's import valid.

I think so. Seem Enzyme didn't updated any release and it is working right when we use cheerio 1.0.0-rc.10. I think cheerio should be backward compatibility

@ygnoh
Copy link

ygnoh commented May 24, 2022

It seems to have the same cause as #2545

@nnegi79
Copy link

nnegi79 commented May 25, 2022

Seems like you are using a deep import of lib/utils. Could you provide some context on what you are trying to accomplish? With that, lib/utils can be added as an exported file.

Enzyme uses a deep import lib/utils (https://github.com/enzymejs/enzyme/blob/master/packages/enzyme/src/Utils.js#L11), so Enzyme and libraries built on Enzyme are failing due to this.
See: enzymejs/enzyme#2558 and enzymejs/enzyme#2559
The second Enzyme issue seems to imply that no immediate fix is coming from Enzyme to correct their import, so it may be easier and faster to add lib/utils as an exported file in Cheerio to make Enzyme's import valid.

I think so. Seem Enzyme didn't updated any release and it is working right when we use cheerio 1.0.0-rc.10. I think cheerio should be backward compatibility

I am also getting the same issue. Because of enzyme;s deep link dependency, build is failing with this error "
Error [ERR_PACKAGE_PATH_NOT_EXPORTED] [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/utils' is not defined by "exports". Do you know any workaround/immediate fix for this?

@Christophe31
Copy link

@nnegi79 I think I'll lock 1.0.0-rc.10

@zburke
Copy link

zburke commented May 31, 2022

We have the same sort of error:

Error: Package subpath './lib/utils' is not defined by "exports"...

but IIUC @fb55 is telling us, "We changed some private implementation details in the latest release, but that shouldn't matter if you consume our public exports, which did not change. Enzyme must rely on some of the private implementation details that we changed." IOW, "Cheerio isn't broken, Enzyme is (and always was, we just didn't know until now)."

@fb55
Copy link
Member

fb55 commented Jun 1, 2022

@zburke The truth is that I didn't know about enzyme's dependency when adding exports in the package.json. I also would have added the exports by now if there weren't some other issues with enzyme (see #2547 and #1585).

As enzyme recommends users stay with 1.0.0-rc.3, I honestly still don't have a good way forward.

@thyoondev
Copy link

a temporary solution for this case :

//edit node_modules/cheerio/package.json 

...

  "exports": {
    ".": {
      "require": "./lib/index.js",
      "import": "./lib/esm/index.js"
    },
    "./lib/slim": {
      "require": "./lib/slim.js",
      "import": "./lib/esm/slim.js"
    },
    "./lib/utils": {
      "require": "./lib/utils.js",
      "import": "./lib/esm/utils.js"
    }
  },
  
 ...

@yehor-anisimov
Copy link

yehor-anisimov commented Oct 4, 2024

In case someone looking for solution. You should lock cheerio version in your package.json

"cheerio": "1.0.0-rc.3",

npm list cheerio
@projectname
├── [email protected]
└─┬ [email protected]
  └── [email protected] deduped

nikolas added a commit to ccnmtl/stats-interactives that referenced this issue Oct 14, 2024
Also, fixed the jest tests by locking the version of `cheerio`
cheeriojs/cheerio#2547 (comment)
nikolas added a commit to ccnmtl/stats-interactives that referenced this issue Oct 14, 2024
Also, fixed the jest tests by locking the version of `cheerio`
cheeriojs/cheerio#2547 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

10 participants