You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are error codes linked to package exports in node.js, but these are absent when using PnP.
Those codes are useful when trying to figure out what is going wrong. Their absence also makes require and require.resolve harder to work with in tools that try to provide useful error messages to users.
The following codes are present within node, though the list is just a quick lookup in node's code so possibly not exhaustive:
ERR_INVALID_PACKAGE_CONFIG
ERR_INVALID_PACKAGE_TARGET
ERR_PACKAGE_IMPORT_NOT_DEFINED (for imports, which yarn doesn't support yet afaik)
Error: expect(received).resolves.toHaveProperty(path, value)
Expected path: "code"
Received path: []
Expected value: "ERR_PACKAGE_PATH_NOT_EXPORTED"
Received value: {}
at Object.toHaveProperty (/github/workspace/.yarn/cache/expect-npm-24.8.0-8c7640c562-0c0da74930.zip/node_modules/expect/build/index.js:202:20)
at module.exports (evalmachine.<anonymous>:8:68)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async /github/workspace/.yarn/cache/@arcanis-sherlock-npm-2.0.2-91650a2501-627bee24a7.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:56:13
at async executeInTempDirectory (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-2.0.2-91650a2501-627bee24a7.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:17:16)
at async Object.executeRepro (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-2.0.2-91650a2501-627bee24a7.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:24:12)
at async ExecCommand.execute (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-2.0.2-91650a2501-627bee24a7.zip/node_modules/@arcanis/sherlock/lib/commands/exec.js:25:38)
at async ExecCommand.validateAndExecute (/github/workspace/.yarn/cache/clipanion-npm-2.0.0-rc.16-b9444aaf89-91cf93ba72.zip/node_modules/clipanion/lib/advanced/Command.js:161:26)
at async Cli.run (/github/workspace/.yarn/cache/clipanion-npm-2.0.0-rc.16-b9444aaf89-91cf93ba72.zip/node_modules/clipanion/lib/advanced/Cli.js:74:24)
at async Cli.runExit (/github/workspace/.yarn/cache/clipanion-npm-2.0.0-rc.16-b9444aaf89-91cf93ba72.zip/node_modules/clipanion/lib/advanced/Cli.js:83:28)
I see… This isn't purely about the validation (though that's certainly linked) but the fact that require.resolve in PnP can now throw errors that don't have a code, which is unexpected.
I think the errors it explicitly throws would have code ERR_PACKAGE_PATH_NOT_EXPORTED in node itself, though implicit errors (e.g. if exports is an array) can also pop up and those would require another code.
Self-service
Describe the bug
There are error codes linked to package exports in node.js, but these are absent when using PnP.
Those codes are useful when trying to figure out what is going wrong. Their absence also makes
require
andrequire.resolve
harder to work with in tools that try to provide useful error messages to users.The following codes are present within node, though the list is just a quick lookup in node's code so possibly not exhaustive:
ERR_INVALID_PACKAGE_CONFIG
ERR_INVALID_PACKAGE_TARGET
ERR_PACKAGE_IMPORT_NOT_DEFINED
(for imports, which yarn doesn't support yet afaik)ERR_PACKAGE_PATH_NOT_EXPORTED
ERR_UNSUPPORTED_DIR_IMPORT
To reproduce
Environment
System: OS: macOS 11.6 CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz Binaries: Node: 14.17.6 - /private/var/folders/_d/ch2kc4h960d10cy_2c41qqzw0000gn/T/xfs-a1ff373c/node Yarn: 3.1.0 - /private/var/folders/_d/ch2kc4h960d10cy_2c41qqzw0000gn/T/xfs-a1ff373c/yarn npm: 6.14.15 - ~/.nvm/versions/node/v14.17.6/bin/npm
Additional context
No response
The text was updated successfully, but these errors were encountered: