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

Strange issue #7

Closed
midzdotdev opened this issue Jan 19, 2021 · 6 comments
Closed

Strange issue #7

midzdotdev opened this issue Jan 19, 2021 · 6 comments

Comments

@midzdotdev
Copy link

I just tried to bring in this library into my Next application and I got this strange error.

It's referring to a /flattedpackage.json, which obviously doesn't exist. Have you come across anything like this before?

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './cjs' is not defined by "exports" in /Users/james/code/pavement/node_modules/flattedpackage.json
    at applyExports (internal/modules/cjs/loader.js:518:9)
    at resolveExports (internal/modules/cjs/loader.js:534:23)
    at Function.Module._findPath (internal/modules/cjs/loader.js:666:31)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1067:27)
    at Function.Module._load (internal/modules/cjs/loader.js:923:27)
    at Module.require (internal/modules/cjs/loader.js:1140:19)
    at require (internal/modules/cjs/helpers.js:75:18)
    at Object.<anonymous> (/Users/james/code/pavement/node_modules/react-contentful/ContentfulCache.js:6:15)
    at Module._compile (internal/modules/cjs/loader.js:1251:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1272:10)
    at Module.load (internal/modules/cjs/loader.js:1100:32)
    at Function.Module._load (internal/modules/cjs/loader.js:962:14)
    at Module.require (internal/modules/cjs/loader.js:1140:19)
    at require (internal/modules/cjs/helpers.js:75:18)
    at Object.<anonymous> (/Users/james/code/pavement/node_modules/react-contentful/index.js:8:47)
    at Module._compile (internal/modules/cjs/loader.js:1251:30) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
@ryanhefner
Copy link
Owner

@james2mid Weird, this is new to me, let me see what's up. What version of Next are you using?

@midzdotdev
Copy link
Author

The latest, 10.0.5.

Also, it seems as though the problem is actually with the react-contentful package. I excluded next-contentful package and the same happened.

@midzdotdev
Copy link
Author

I've managed to reproduce the bug here.

As you can tell, I'm using this starter. It must be to do with the configuration, potentially babel?

@therebelrobot
Copy link

therebelrobot commented Jan 28, 2021

I ran into this as well. It's because react-contentful is referencing flatted/cjs here.

I fixed this by using patch-package and locally fixing that line to reference flatted directly, kinda gnarly. If possible, an issue should be opened on react-contentful to fix this, as it can't even be resolved via selective dependency resolution.

Note: I have since found a similar reference in this library here, but the above fix solved the compile error, not sure why this one works

@ryanhefner
Copy link
Owner

@james2mid I just pushed a patch to react-contentful that should resolve the import. Updating this package now to use the latest version. Should be up within the next couple of minutes.

And, apologies for the delay on getting to this, and I appreciate the time you have put in on troubleshooting this. Much appreciated and I will try to be more prompt if any future issues pop up!

@ryanhefner
Copy link
Owner

@therebelrobot I pushed up an update that should address that. Let me know if that resolve the issue for you. Hopefully you’ll be able to drop the patch-package stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants