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

[BUG] <title> login Remote Windows use SSH with powershell,but npm not work #8102

Open
2 tasks done
zwfengineer opened this issue Feb 12, 2025 · 1 comment
Open
2 tasks done
Labels
Bug thing that needs fixing Needs Triage needs review for next steps platform:windows is Windows-specific

Comments

@zwfengineer
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

Image

Expected Behavior

No response

Steps To Reproduce

  1. In this environment...
  2. With this config...
  3. Run '...'
  4. See error...

Environment

  • npm:10.8.2
  • Node.js:v20.18.0
  • OS Name:win10 10.0.19045
  • System Model Name:
  • npm config:
; copy and paste output from `npm config ls` here
@zwfengineer zwfengineer added Bug thing that needs fixing Needs Triage needs review for next steps labels Feb 12, 2025
@zwfengineer zwfengineer changed the title [BUG] <title> login Remote Windows use SSH ,but npm not work ,use powershell [BUG] <title> login Remote Windows use SSH with powershell,but npm not work Feb 12, 2025
@zwfengineer
Copy link
Author

use chatgpt write .ps1 shell

# Enable strict mode
Set-StrictMode -Version Latest

# Get the directory of the current script
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition

# Determine the Node.js executable
$nodeExe = Join-Path $scriptDir "node.exe"
if (-Not (Test-Path $nodeExe)) {
    $nodeExe = "node"  # Use global node if not found locally
}

# Determine npm-related script paths
$npmPrefixJs = Join-Path $scriptDir "node_modules/npm/bin/npm-prefix.js"
$npmCliJs = Join-Path $scriptDir "node_modules/npm/bin/npm-cli.js"

# Get the global npm path
$npmPrefixNpmCliJs = ""
if (Test-Path $npmPrefixJs) {
    $npmPrefix = & $nodeExe $npmPrefixJs 2>$null
    if ($npmPrefix) {
        $npmPrefixNpmCliJs = Join-Path $npmPrefix "node_modules/npm/bin/npm-cli.js"
    }
}

# Use global npm-cli.js if it exists
if (Test-Path $npmPrefixNpmCliJs) {
    $npmCliJs = $npmPrefixNpmCliJs
}

# Execute npm command
& $nodeExe $npmCliJs @Args

@milaninfy milaninfy added the platform:windows is Windows-specific label Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps platform:windows is Windows-specific
Projects
None yet
Development

No branches or pull requests

2 participants