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

require from command line does not work #64

Closed
bhvngt opened this issue Feb 21, 2022 · 3 comments · Fixed by #68
Closed

require from command line does not work #64

bhvngt opened this issue Feb 21, 2022 · 3 comments · Fixed by #68

Comments

@bhvngt
Copy link

bhvngt commented Feb 21, 2022

#31 seems to have introduced a bug.

When I try to use node -r dotenv-expand/config, it throws following error

❯ node -r dotenv-expand/config
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/env-options' is not defined by "exports" in /home/projects/node-bdyl5f/node_modules/dotenv/package.json
    at throwExportsNotFound (https://node-bdyl5f.w.staticblitz.com/blitz.d64d45524a435df425e7813603b52872ecfbe08e.js:6:488525)
    at packageExportsResolve (https://node-bdyl5f.w.staticblitz.com/blitz.d64d45524a435df425e7813603b52872ecfbe08e.js:6:491222)
    at resolveExports (https://node-bdyl5f.w.staticblitz.com/blitz.d64d45524a435df425e7813603b52872ecfbe08e.js:6:182519)
    at Function.Module._findPath (https://node-bdyl5f.w.staticblitz.com/blitz.d64d45524a435df425e7813603b52872ecfbe08e.js:6:183031)
    at Function.Module._resolveFilename (https://node-bdyl5f.w.staticblitz.com/blitz.d64d45524a435df425e7813603b52872ecfbe08e.js:6:188095)
    at Function.Module._load (https://node-bdyl5f.w.staticblitz.com/blitz.d64d45524a435df425e7813603b52872ecfbe08e.js:6:185865)
    at Module.require (https://node-bdyl5f.w.staticblitz.com/blitz.d64d45524a435df425e7813603b52872ecfbe08e.js:6:189078)
    at i (https://node-bdyl5f.w.staticblitz.com/blitz.d64d45524a435df425e7813603b52872ecfbe08e.js:6:443011)
    at _0x4248b4 (https://node-bdyl5f.w.staticblitz.com/blitz.d64d45524a435df425e7813603b52872ecfbe08e.js:15:95063)
    at eval (/home/projects/node-bdyl5f/node_modules/dotenv-expand/config.js:6:7) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

This is due to lib/cli-options and lib/env-options are not exported from dotenv.

After monkey patching the exports under node_modules/dotenv/package.json with exports: {"./lib/*": "./lib/*.js"} I get another error

❯ node -r dotenv-expand/config
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/env-options' is not defined by "exports" in /home/projects/node-bdyl5f/node_modules/dotenv/package.json
    at throwExportsNotFound (https://node-bdyl5f.w.staticblitz.com/blitz.d64d45524a435df425e7813603b52872ecfbe08e.js:6:488525)
    at packageExportsResolve (https://node-bdyl5f.w.staticblitz.com/blitz.d64d45524a435df425e7813603b52872ecfbe08e.js:6:491222)
    at resolveExports (https://node-bdyl5f.w.staticblitz.com/blitz.d64d45524a435df425e7813603b52872ecfbe08e.js:6:182519)
    at Function.Module._findPath (https://node-bdyl5f.w.staticblitz.com/blitz.d64d45524a435df425e7813603b52872ecfbe08e.js:6:183031)
    at Function.Module._resolveFilename (https://node-bdyl5f.w.staticblitz.com/blitz.d64d45524a435df425e7813603b52872ecfbe08e.js:6:188095)
    at Function.Module._load (https://node-bdyl5f.w.staticblitz.com/blitz.d64d45524a435df425e7813603b52872ecfbe08e.js:6:185865)
    at Module.require (https://node-bdyl5f.w.staticblitz.com/blitz.d64d45524a435df425e7813603b52872ecfbe08e.js:6:189078)
    at i (https://node-bdyl5f.w.staticblitz.com/blitz.d64d45524a435df425e7813603b52872ecfbe08e.js:6:443011)
    at _0x4248b4 (https://node-bdyl5f.w.staticblitz.com/blitz.d64d45524a435df425e7813603b52872ecfbe08e.js:15:95063)
    at eval (/home/projects/node-bdyl5f/node_modules/dotenv-expand/config.js:6:7) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

This requires changes in the following line of config.js

return dotenvExpand(env) => return dotenvExpand.expand(env).

After this, the command works out fine.

The issue can be reproduced here

@c1moore
Copy link
Contributor

c1moore commented Mar 4, 2022

I'm also seeing this error.

@nenadfilipovic
Copy link

Same problem.

@c1moore
Copy link
Contributor

c1moore commented Mar 12, 2022

@motdotla I was mistaken, my change alone does not fix this issue.

@c1moore c1moore mentioned this issue Mar 12, 2022
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

Successfully merging a pull request may close this issue.

3 participants