Comments (13)
Thanks for the issue! Did not think of it, because we do export package.json
's from our own packages. I'll fix it withing a day.
from jest-node-exports-resolver.
Great, thanks :-D
from jest-node-exports-resolver.
It's actually not so easy to fix :) using require.resolve(PACKAGE_NAME)
directly against a package with no "main" field specified (i.e. @babel/runtime
) results in ERR_PACKAGE_PATH_NOT_EXPORTED
error. So I'm going to combine both approaches. Could you please reference the package you're getting in trouble with so I could test solutions with it?
from jest-node-exports-resolver.
It's actually not so easy to fix :) using
require.resolve(PACKAGE_NAME)
directly against a package with no "main" field specified (i.e.@babel/runtime
) results inERR_PACKAGE_PATH_NOT_EXPORTED
error.
Looks strange, specially since require()
uses require.resolve()
internally...
Could you please reference the package you're getting in trouble with so I could test solutions with it?
It's currently a private one, but I can give you access to it.
from jest-node-exports-resolver.
Just released v1.0.3 with fallback to require.resolve()
in case of non-exported package.json
, could you please check if the problem is fixed?
from jest-node-exports-resolver.
Closing for now. Feel free to reopen if problem isn't fixed for your setup.
from jest-node-exports-resolver.
Hi @k-g-a, it seems at least for jest
internal resolution of environment setup is not working. Must to admit, it's NOT the same use case I faced before, I'll try it later.
Could not retrieve package.json neither through require (package.json itself is not within "exports" field), nor through require.resolve (package.json does not specify "main" field) - falling back to default resolver logic
Failed to find package.json for @mafalda/mafalda-api
● Validation Error:
Module @mafalda/mafalda-api/expect in the setupFilesAfterEnv option was not found.
<rootDir> is: /home/piranna/github/Mafalda/Mafalda
Configuration Documentation:
https://jestjs.io/docs/configuration
from jest-node-exports-resolver.
Hi!
Could you please try to replace requestPath
with plain incoming request
in findMainPackageJson(requestPath, packageName)
at 57 line? If it works, I'll publish it as a fix.
But it's quite strange you face that error, because './package.json' is exported from your mafalda/mafalda-api
pakcage.json's exports, so packageJson = require(
${packageName}/package.json);
should do it's work.
from jest-node-exports-resolver.
With package.json
entry it works, and both without it I get in latest published version or with your proposed change this error:
Could not retrieve package.json neither through require (package.json itself is not within "exports" field), nor through require.resolve (package.json does not specify "main" field) - falling back to default resolver logic
from jest-node-exports-resolver.
As far as I get it: everything works as expected if the package.json is exported, but neither 1.0.0 nor 1.0.3 work if not?
from jest-node-exports-resolver.
Yes, that's it.
from jest-node-exports-resolver.
With latest version, I can't import https://github.com/Mafalda-SFU/FsSet too without adding the package.json
entry.
(Yes, ./
entry should be .
, I have it already fixed)
from jest-node-exports-resolver.
This also fails when the value of exports
field is a string instead of a mapping object.
from jest-node-exports-resolver.
Related Issues (11)
- Doesn't Appear to work with Top level node Exports HOT 6
- "setupFiles" and "setupFilesAfterEnv" Jest options do not work properly when using jest-node-exports-resolver HOT 2
- Doesn't seem to work with @firebase/auth
- Doesn't work for older versions of Jest HOT 3
- findMainPackageJson() doesn't work properly on Windows HOT 1
- Get `Cannot find module` error after upgrade to Jest 29.0.0+ HOT 3
- Not working accessing files in scoped packages HOT 3
- Don't work with `exports` as string HOT 1
- Doesn't work with `ws` module HOT 3
- Since 1.1.3 'Cannot use import statement outside a module' HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jest-node-exports-resolver.