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
If a TypeScript file imports an NPM package whose package.json contains subpath exports, the loader crashes with Error [ERR_PACKAGE_PATH_NOT_EXPORTED].
sunny@box1:~/code/bug$ npm run dev
> dev
> node --loader @k-foss/ts-esnode --experimental-specifier-resolution=node main.ts
(node:251905) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:251905) Warning: The dynamicInstantiate loader hook has been removed.
node:internal/process/esm_loader:74
internalBinding('errors').triggerUncaughtException(
^
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/main.js' is not defined by "exports"in /home/sunny/code/bug/node_modules/dotenv/package.json
at new NodeError (node:internal/errors:363:5)
at throwExportsNotFound (node:internal/modules/esm/resolve:321:9)
at packageExportsResolve (node:internal/modules/esm/resolve:546:3)
at resolveExports (node:internal/modules/cjs/loader:478:36)
at Function.Module._findPath (node:internal/modules/cjs/loader:518:31)
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:927:27)
at Function.Module._load (node:internal/modules/cjs/loader:774:27)
at Module.require (node:internal/modules/cjs/loader:1013:19)
at require (node:internal/modules/cjs/helpers:93:18)
at getSource (file:///home/sunny/code/bug/node_modules/@k-foss/ts-esnode/out/dist/index.js:131:27) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
It isn't allowable to require("dotenv/lib/main.js"); due to this subpath exports specification.
Instead, the loader should invoke require("dotenv"), i.e. do not resolve export subpath to the actual file.
Environment
Node 16.1.0
NPM 7.11.2
TS-ESNode 2.0.2
The text was updated successfully, but these errors were encountered:
If a TypeScript file imports an NPM package whose
package.json
contains subpath exports, the loader crashes withError [ERR_PACKAGE_PATH_NOT_EXPORTED]
.Files to Reproduce
package.json
tsconfig.json
main.ts
Error Message
Analysis
node_modules/dotenv/package.json contains:
It isn't allowable to
require("dotenv/lib/main.js");
due to this subpath exports specification.Instead, the loader should invoke
require("dotenv")
, i.e. do not resolve export subpath to the actual file.Environment
The text was updated successfully, but these errors were encountered: