Question Details

No question body available.

Tags

powershell dotenv npm-publish

Answers (1)

February 16, 2026 Score: 1 Rep: 454,491 Quality: Medium Completeness: 80%

In a PowerShell session, dotenv refers to a script named dotenv.ps1, i.e. a PowerShell script.

The problem is that PowerShell's parameter binder "eats" an (unquoted) -- argument passed to a PowerShell-native command such as .ps1 script, because it is interpreted as a treat-all-subsequent-arguments-as-positional signal for the command itself[1] rather than as a pass-through argument.

In the case at hand this means that the -- does not get passed through to the Node.js code implementing the CLI's functionality, causing the call to malfunction.

Choose one of the following workarounds:

# Option A: double the --
dotenv -- -- npm publish --tag experimental  

Option B: quote the --

dotenv '--' npm publish --tag experimental

Option C: call via the .cmd (bath file) of the same name that

also comes with npm packages that have CLIs.

Caveats:

This workaround is specific to npm-installed packages.

* It can result in subtly different treatment of the pass-through arguments,

due to cmd.exe parsing them (too).

dotenv.cmd -- npm publish --tag experimental

Note that the described behavior generally complicates the implementation of any CLI that should pass -- through as-is as a PowerShell script or function, because only in direct calls to external programs does PowerShell pass -- through as-is.

GitHub issue #21208 discusses this problem, and includes a proposal to introduce an attribute that functions and scripts could be decorated with to designate them as general-purpose CLIs that pass -- through too.


[1] PowerShell calls -- the end-of-parameters token.