Comments (7)
I think it was a user permissions problem within ProgramData
from pm2-installer.
@dev-syn How did you solve this ? Nothing seems to work.
from pm2-installer.
"npm run setup" works on the old powershell started as a terminal but not on the new one.
from pm2-installer.
"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.
"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.
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.
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)
- Could not start service
- dont work with cluster mode HOT 1
- Potentially Dangerous PATH Variables C:\ProgramData\npm\npm : builtin\users HOT 1
- pm2 start issue HOT 3
- NPM as spawned child process does not work HOT 1
- Unrecognized token in source text - setup script
- No permission to Set-Permissions HOT 2
- pm2 logrotate got stuck with install
- Apps started according to pm2, but they are not running any service HOT 1
- Will this help me avoid "terminal" spawn issue ? HOT 1
- App shows as started on pm2 ls but it's frozen and doesn't get a PID. HOT 5
- In-memory PM2 is out-of-date HOT 1
- Offline install error HOT 1
- Moving PM2 logs output directory outside C:\ProgramData
- Error: ENOENT: no such file or directory
- No "shutdown" message is sent when the service is stopped
- Network Drive issue
- NPM as exec child process does not work
- There's always error when using this package
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pm2-installer.