GithubHelp home page GithubHelp logo

Comments (7)

dev-syn avatar dev-syn commented on July 28, 2024

I think it was a user permissions problem within ProgramData

from pm2-installer.

punowo avatar punowo commented on July 28, 2024

@dev-syn How did you solve this ? Nothing seems to work.

from pm2-installer.

punowo avatar punowo commented on July 28, 2024

"npm run setup" works on the old powershell started as a terminal but not on the new one.

from pm2-installer.

dev-syn avatar dev-syn commented on July 28, 2024

"npm run setup" works on the old powershell started as a terminal but not on the new one.

Good to know to be honest I gave up because I thought it was a problem within my own computer with permissions. I did a reset recently and haven't touched permissions nor tried setting this up again but when I do I will try that

from pm2-installer.

punowo avatar punowo commented on July 28, 2024

"npm run setup" works on the old powershell started as a terminal but not on the new one.

Good to know to be honest I gave up because I thought it was a problem within my own computer with permissions. I did a reset recently and haven't touched permissions nor tried setting this up again but when I do I will try that

I'm lucky enough to have to have full access to my work machine but I'm restricted to a windows environment due to certain factors so I ended up practically trying everything in a weekend.
I still encounter this #86 but once I change to "Local System Account" I didn't encounter any other problems except the one where pm2 doesn't care about 'npm' on Windows and you have to pass on the full npm-cli.js path as 'script' in the ecosystem file.

from pm2-installer.

Aki-Siponen avatar Aki-Siponen commented on July 28, 2024

I'm running PowerShell 7.3.4

The cause of this error is incompatibility of PowerShell Core (pwsh, version 7.x) and PowerShell (version 5.x) core modules, specifically Microsoft.PowerShell.Security.
npm runs the setup in PowerShell, not in PowerShell Core.
When you try to run setup from pwsh, what setup is doing is starting Command Prompt to start node to start Command Prompt to ... start PowerShell.
PowerShell is effectively running on top of pwsh. I guess that PowerShell does not support loading core modules in this situation. At least document here explains that (starting from PowerShell 7.1) core PowerShell modules cannot be loaded in compatibility mode.

You could get rid of the error by adding these lines to start of src/windows/setup.ps1:

# Write-Host "Checking how this all started."
# Get-Process -Id $PID
$wmi = Get-WmiObject Win32_Process -Filter "ProcessId=$($pid)"
do {
  $process = Get-Process -Id $wmi.ParentProcessId -ErrorAction SilentlyContinue
  # $process # for debugging
  if ($process.Name -eq 'pwsh') {
    Write-Host "The  setup cannot be started from PowerShell Core (pwsh, PowerShell version 7.x).`nPlease run the setup from Powershell (version 5.x)."
    exit(1)
  }
  $wmi = Get-WmiObject Win32_Process -Filter "ProcessId=$($wmi.ParentProcessId)" -ErrorAction SilentlyContinue
} until ($wmi.ParentProcessId -eq $null)

That would prevent setup running in PowerShell Core.

If you would want to run setup in PowerShell Core, you'd need to change "PowerShell" to "pwsh" in all package.json scripts.

from pm2-installer.

dev-syn avatar dev-syn commented on July 28, 2024

I'm running PowerShell 7.3.4

The cause of this error is incompatibility of PowerShell Core (pwsh, version 7.x) and PowerShell (version 5.x) core modules, specifically Microsoft.PowerShell.Security. npm runs the setup in PowerShell, not in PowerShell Core. When you try to run setup from pwsh, what setup is doing is starting Command Prompt to start node to start Command Prompt to ... start PowerShell. PowerShell is effectively running on top of pwsh. I guess that PowerShell does not support loading core modules in this situation. At least document here explains that (starting from PowerShell 7.1) core PowerShell modules cannot be loaded in compatibility mode.

You could get rid of the error by adding these lines to start of src/windows/setup.ps1:

# Write-Host "Checking how this all started."
# Get-Process -Id $PID
$wmi = Get-WmiObject Win32_Process -Filter "ProcessId=$($pid)"
do {
  $process = Get-Process -Id $wmi.ParentProcessId -ErrorAction SilentlyContinue
  # $process # for debugging
  if ($process.Name -eq 'pwsh') {
    Write-Host "The  setup cannot be started from PowerShell Core (pwsh, PowerShell version 7.x).`nPlease run the setup from Powershell (version 5.x)."
    exit(1)
  }
  $wmi = Get-WmiObject Win32_Process -Filter "ProcessId=$($wmi.ParentProcessId)" -ErrorAction SilentlyContinue
} until ($wmi.ParentProcessId -eq $null)

That would prevent setup running in PowerShell Core.

If you would want to run setup in PowerShell Core, you'd need to change "PowerShell" to "pwsh" in all package.json scripts.

Thanks for pointing this out if I return to pm2 I will definitely remember this.

from pm2-installer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.