-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
Can't self-reference a scoped package using its name #37618
Comments
Jest issue at jestjs/jest#11161 |
The following example works, so I'd say it's probably a bug in package.json: {
"name": "@my/package",
"exports": "./index.js"
} index.js module.exports = 42 other.js console.log(require('@my/package')) $ node other.js
42 |
Thanks for confirm it, then now it's a matter of getting a response on their side. I'll open a PR in the docs specifying this use case, since it's not obvious in its current state :-) I think we can close this now. |
Original code by @targos from nodejs#37618 (comment) Closes nodejs#37618
Original code by Michaël Zasso 'targos' from nodejs#37618 (comment) Closes nodejs#37618
|
PR-URL: #37630 Fixes: #37618 Refs: #37618 (comment) Co-authored-by: Michaël Zasso <targos@protonmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com>
PR-URL: #37630 Fixes: #37618 Refs: #37618 (comment) Co-authored-by: Michaël Zasso <targos@protonmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com>
PR-URL: #37630 Fixes: #37618 Refs: #37618 (comment) Co-authored-by: Michaël Zasso <targos@protonmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com>
Not sure if it's a Node.js or
jest-resolve
issue, so I'm cross-posting it.What steps will reproduce the bug?
At Node.js packages docs it says it's possible to self-reference and import a package from it's own modules by using the package name, the same was as it's done with dependencies installed on
node_modules
. I'm self-referencing my package itself in myjest
tests, it says it can't find it:Since my package has a scope (package name is in the form with
@<scope>/<packageName>
) and there's no examples or references in Node.js docs about self-referencing scoped packages, maybe this is a Node.js packages resolving algorythm.How often does it reproduce? Is there a required condition?
It happens me always. Maybe related to
jest-resolve
package.What is the expected behavior?
The self-referenced package should be imported.
What do you see instead?
It give an error stating it can't find the module.
Additional information
I'm trying to do it that way in combination with package.json imports and Jest
projects
andtestEnvironment
, I can be able to test my code in multiple environments doing different imports for each one, so I can apply polyfills automatically.The text was updated successfully, but these errors were encountered: