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

--resolve-engines in combination with --use-on-cd for cmd/cmder does not seem to work #1372

Open
nicklastromb opened this issue Jan 22, 2025 · 0 comments

Comments

@nicklastromb
Copy link

The fix for #1100 in PR #1259 does not seem to fix the issue when using Windows CMD/CMDER with --use-on-cd --resolve-engines.

The expected behavior is that the engines should be resolved on cd from the package.json file but for cmd and cmder this does not seem to be the case. PowerShell seems to work without any issues.

fnm version: 1.38.1
fnm installed through: scoop
OS: Windows 11 24H2
Shell: cmd and cmder

package.json

{
    ...
    "engines": {
        "node": ">=20.10.0 <21"
      },
    ...
}

When browsing to a folder in cmd/cmder fnm does not resolve the engines from the package.json file, if performing fnm use after browsing to the folder fnm correctly resolves the node version.

CMD

Init script for CMD

@echo off
:: for /F will launch a new instance of cmd so we create a guard to prevent an infnite loop
if not defined FNM_AUTORUN_GUARD (
    set "FNM_AUTORUN_GUARD=AutorunGuard"
    FOR /f "tokens=*" %%z IN ('fnm env --use-on-cd --resolve-engines') DO CALL %%z
    echo "Initialized fnm (CMD)"
)

Image

CMDER

Init script for CMDER

@echo off
if not defined FNM_AUTORUN_GUARD (
    set "FNM_AUTORUN_GUARD=AutorunGuard"
    FOR /f "tokens=*" %%z IN ('fnm env --use-on-cd --resolve-engines') DO CALL %%z
    echo "Initialized fnm (cmder)"
)

Image

Image

PowerShell

When using PowerShell this seem to work correctly

Init script for PowerShell

fnm env --use-on-cd --resolve-engines --shell powershell | Out-String | Invoke-Expression
echo "Initialized fnm (PowerShell)"

Image

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

1 participant