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

dotenv-expand: TypeError: Cannot read property 'split' of undefined #71

Closed
andrii-lundiak opened this issue Apr 1, 2022 · 6 comments
Closed

Comments

@andrii-lundiak
Copy link

$ npm run cypress:run:new

> end-to-end@1.0.0 cypress:run:new C:\projects\e2e_ssh
> dotenv cross-var cypress run

C:\projects\e2e_ssh\node_modules\dotenv-expand\lib\main.js:20
      const keyParts = parts[2].split(':-')
                                ^

TypeError: Cannot read property 'split' of undefined
    at C:\projects\e2e_ssh\node_modules\dotenv-expand\lib\main.js:20:33
    at Array.reduce (<anonymous>)
    at _interpolate (C:\projects\e2e_ssh\node_modules\dotenv-expand\lib\main.js:6:18)
    at expand (C:\projects\e2e_ssh\node_modules\dotenv-expand\lib\main.js:50:32)
    at C:\projects\e2e_ssh\node_modules\dotenv-cli\cli.js:74:3
    at Array.forEach (<anonymous>)
    at Object.<anonymous> (C:\projects\e2e_ssh\node_modules\dotenv-cli\cli.js:73:7)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! end-to-end@1.0.0 cypress:run:new: `dotenv cross-var cypress run`
npm ERR! Exit status 1

node v14
npm v6
dotenv@^16.0.0
dotenv-cli@5.1.0 (with required dotenv-expand@^8.0.1 )

Works ONLY with no such error when I downgrade to dotenv-cli@4.1.1 which under the hood installs dotenv-expand@^5.1.0

@entropitor
Copy link
Owner

Seems like a bug in dotenv-expand. Not sure why the newer version doesn't work but nothing we can do about that. I'm pretty sure dotenv-expand as a library will have the same bug

@mishabruml
Copy link

experiencing this on dotenv 5

@wilsonpage
Copy link

wilsonpage commented Sep 30, 2022

I found that this is related to some special-chars in my .env. Commenting those lines out avoids the error. But yes, this is still a bug in dotenv-expand.

@DollarAkshay
Copy link

@wilsonpage You are right.

This is kinda stupid. I have a $ sign inside my .env file as it is part of a password and now this library doesnt work because of that ?

@entropitor
Copy link
Owner

Try quoting it, if it doesn't work, file a bug over at dotenv-expand as "this library" doesn't do any parsing.

@andrii-lundiak
Copy link
Author

andrii-lundiak commented Nov 14, 2022

Hi :) Good to see some activity under my issue, which had been closed already by @entropitor - but it's ok.

I wanna say, that that at the time of report I'd experimenting with cross-env dotenv and dotenv cross-var and a few other approaches to somehow bring variable from .env to package.json. And now considering that MY .env file has many other things, I will research (cleanup/delete/etc) and will update this ticket later.

Here is my full list of experiments:

    "cypress:run": "cypress run",
    "cypress:run:new1": "cross-env CYPRESS_BASE_URL=http://localhost cypress run",
    "cypress:run:new2": "cross-env dotenv cypress run",
    "cypress:run:new3": "cross-env dotenv cross-var cypress run",
    "cypress:run:new8": "export $(cat .env | xargs) && npm run cypress:run:auth",
    "cypress:run:new9": "export $(cat .env | grep \"^[^#;]\" | xargs) && cypress run",

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

No branches or pull requests

5 participants