dotenvx: dotenvx run doesn't run under powershell

dotenvx -V 1.22.0

This command doesn’t run in Powershell: dotenvx run -f .env.testing -- node index.js

In pwsh:

PS D:\temp> dotenvx run -f .env.testing -- node index.js
[dotenvx@1.22.0] missing node file (D:\temp\node)
? add one with [echo "HELLO=World" > node] and re-run [dotenvx run -- ]
[dotenvx@1.22.0] injecting env (0) from .env.testing, index.js
missing command after [dotenvx run --]

  get help: [dotenvx help run]
  or try:   [dotenvx run -- npm run dev]

If I run it under cmd it runs correctly.

Seems very similar to https://github.com/dotenvx/dotenvx/issues/309

image

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 16 (7 by maintainers)

Most upvoted comments

– is a speical token The end-of-parameters token in powershell, so we need to pass – twice like dotenvx run -f .env.testing -- -- node index.js

thank you. this is very helpful.

a few more bits of information since I think this might be related to npm run and global vs local installs.

is your dotenv-cli (dotenv) also installed globally? can you give me the redacted output of any/all of the following commands: this way I can just be sure we are isolating to a local repo install only.

I have everything installed locally and not globally. See attached image. Output attached as well.

image

PS D:\temp\dotenvx> Get-Command dotenv

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
ExternalScript  dotenv.ps1                                                    D:\temp\dotenvx\node_modules\.bin\dotenv.ps1


PS D:\temp\dotenvx> where dotenv
PS D:\temp\dotenvx> npm list -g dotenv-cli
C:\Users\andy\scoop\apps\nvm\current\nodejs\nodejs -> .\
└── (empty)

npm notice
npm notice New minor version of npm available! 10.8.2 -> 10.9.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.9.0
npm notice To update run: npm install -g npm@10.9.0
npm notice
PS D:\temp\dotenvx> Get-Command dotenvx

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
ExternalScript  dotenvx.ps1                                                   D:\temp\dotenvx\node_modules\.bin\dotenvx.ps1


PS D:\temp\dotenvx> whereis dotenvx
dotenvx: /cygdrive/d/temp/dotenvx/node_modules/.bin/dotenvx /cygdrive/d/temp/dotenvx/node_modules/.bin/dotenvx.cmd /cygdrive/d/temp/dotenvx/node_modules/.bin/dotenvx.ps1
PS D:\temp\dotenvx> npm list -g @dotenvx/dotenvx
C:\Users\andy\scoop\apps\nvm\current\nodejs\nodejs -> .\
└── (empty)

PS D:\temp\dotenvx>