Comments (4)
I tried to run npm run remove
but face this error. I ran in admin mode (cmd). After which I ran on powershell
and it seem alright (see log below)
This is log from running using cmd (admin mode)
Show logs
C:\Windows\system32>chdir C:\Users\Joseph\Desktop\pm2-installer-3.0.2\pm2-installer-3.0.2
C:\Users\Joseph\Desktop\pm2-installer-3.0.2\pm2-installer-3.0.2>npm run remove
> [email protected] remove C:\Users\Joseph\Desktop\pm2-installer-3.0.2\pm2-installer-3.0.2
> node ./src/tools/script-for-os.js
> [email protected] remove:windows C:\Users\Joseph\Desktop\pm2-installer-3.0.2\pm2-installer-3.0.2
> PowerShell -NoProfile -ExecutionPolicy Bypass src\windows\remove.ps1
=== Remove ===
=== Remove Log Rotation ===
=== Remove Log Rotation Complete ===
=== Remove Service ===
Stopping service, this may take a minute or so..
Found "pm2.exe" service:
State: Stopped
Status: OK
Started: False
Start Mode: Auto
Service Type: Own Process
Start Name: NT AUTHORITY\LocalService
Service is already stopped.
Running pm2 kill..
Running Node service uninstall script..
service-management\uninstall Uninstalling
Uninstalling service "PM2" at "C:\ProgramData\pm2\service"
Uninstalling service..
internal/fs/utils.js:269
throw err;
^
Error: EPERM: operation not permitted, unlink 'C:\ProgramData\pm2\service\daemon\pm2.exe'
at Object.unlinkSync (fs.js:1136:3)
at rm (C:\Users\Joseph\AppData\Roaming\npm\node_modules\node-windows\lib\daemon.js:602:22)
at C:\Users\Joseph\AppData\Roaming\npm\node_modules\node-windows\lib\daemon.js:615:15
at ChildProcess.exithandler (child_process.js:294:7)
at ChildProcess.emit (events.js:315:20)
at maybeClose (internal/child_process.js:1021:16)
at Socket.<anonymous> (internal/child_process.js:443:11)
at Socket.emit (events.js:315:20)
at Pipe.<anonymous> (net.js:674:12) {
errno: -4048,
syscall: 'unlink',
code: 'EPERM',
path: 'C:\\ProgramData\\pm2\\service\\daemon\\pm2.exe'
}
Service uninstall script failed.
At C:\Users\Joseph\Desktop\pm2-installer-3.0.2\pm2-installer-3.0.2\src\windows\remove-service.ps1:92 char:3
+ throw "Service uninstall script failed."
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (Service uninstall script failed.:String) [], RuntimeException
+ FullyQualifiedErrorId : Service uninstall script failed.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] remove:windows: `PowerShell -NoProfile -ExecutionPolicy Bypass src\windows\remove.ps1`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] remove:windows script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Joseph\AppData\Roaming\npm-cache\_logs\2020-08-29T11_56_35_408Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] remove: `node ./src/tools/script-for-os.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] remove script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Joseph\AppData\Roaming\npm-cache\_logs\2020-08-29T11_56_35_563Z-debug.log
This is log from running in powershell (admin mode). Partial logs only, the rest seem to be running fine. I guess this should be fine too?
Show logs
=== Remove Service Complete ===
=== Remove Packages ===
Unlinking node-windows..
npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! network request to https://registry.npmjs.org/@jessety%2feslint-config failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Joseph\AppData\Roaming\npm-cache\_logs\2020-08-29T12_00_25_984Z-debug.log
Uninstalling packages..
removed 185 packages in 14.625s
removed 209 packages in 23.844s
After which I restart my machine, then I try to configure again, this time using powershell - admin mode
Show logs
PS C:\Users\Joseph\Desktop\pm2-installer-3.0.2\pm2-installer-3.0.2> npm run setup
> [email protected] setup C:\Users\Joseph\Desktop\pm2-installer-3.0.2\pm2-installer-3.0.2
> node ./src/tools/script-for-os.js
> [email protected] setup:windows C:\Users\Joseph\Desktop\pm2-installer-3.0.2\pm2-installer-3.0.2
> PowerShell -NoProfile -ExecutionPolicy Bypass src\windows\setup.ps1
=== Setup ===
=== Checking npm Configuration ===
Global npm prefix location does not seem to be in a global location: C:\Users\Joseph\AppData\Roaming\npm
Global npm cache location does not seem to be in a global location: C:\Users\Joseph\AppData\Roaming\npm-cache
npm configuration does not appear valid. The npm prefix and cache must be somewhere accessible to the LocalService user.
(To fix this automatically, execute `npm run configure` beforehand to use C:\ProgramData\npm)
Are you sure you want to proceed anyway? (Y/N): Y
=== Checking npm Configuration Complete ===
=== Install Packages ===
Running on: 8/29/2020, pm2-installer 3.0.2 with node v12.18.3 and npm 6.14.7 on win32-10.0.17763.
Using:
[email protected]
[email protected]
[email protected]
Checking connectivity to the npm registry..
Could not connect to registry.npmjs.org: getaddrinfo ENOTFOUND registry.npmjs.org
Cannot connect to the npm registry. Checking for offline bundle..
Cache tar bundle detected. Decompressing..
Decompressing .\bundle.tar.gz took 6 seconds.
Bundled on: 8/15/2020, pm2-installer 3.0.2 with node v12.16.3 and npm 6.14.7 on win32-10.0.18362.
WARNING: Bundle was created with Node v12.16.3 but this is v12.18.3.
WARNING: Bundle was created on win32-10.0.18362 but this is win32-10.0.17763.
ERROR: Bundle does not match the version of the pm2-installer, node, or npm. This may cause bundled installation to fail. Please ensure bundle is created with the same version as the installation target.
× Offline install bundle appears invalid.
Cache verified and compressed (~\Desktop\pm2-installer-3.0.2\pm2-installer-3.0.2\.npm_cache\_cacache):
Content verified: 376 (9230235 bytes)
Index entries: 573
Finished in 2.313s
Installing packages..
C:\Users\Joseph\AppData\Roaming\npm\pm2-docker -> C:\Users\Joseph\AppData\Roaming\npm\node_modules\pm2\bin\pm2-docker
C:\Users\Joseph\AppData\Roaming\npm\pm2 -> C:\Users\Joseph\AppData\Roaming\npm\node_modules\pm2\bin\pm2
C:\Users\Joseph\AppData\Roaming\npm\pm2-dev -> C:\Users\Joseph\AppData\Roaming\npm\node_modules\pm2\bin\pm2-dev
C:\Users\Joseph\AppData\Roaming\npm\pm2-runtime -> C:\Users\Joseph\AppData\Roaming\npm\node_modules\pm2\bin\pm2-runtime
+ [email protected]
added 185 packages from 191 contributors in 65.843s
+ [email protected]
added 209 packages from 239 contributors in 51.016s
+ [email protected]
added 5 packages from 8 contributors in 1.281s
Installing packages took 125 seconds.
Linking node-windows..
C:\Users\Joseph\Desktop\pm2-installer-3.0.2\pm2-installer-3.0.2\node_modules\node-windows -> C:\Users\Joseph\AppData\Roaming\npm\node_modules\node-windows
Unblocking script at C:\Users\Joseph\AppData\Roaming\npm\pm2.ps1..
=== Install Packages Complete: took 160 seconds ===
=== Creating Service ===
Determining pm2 installation directory..
Determining Local Service user name ("S-1-5-19")..
Configuration:
PM2_HOME: C:\ProgramData\pm2\home
PM2_SERVICE_DIRECTORY: C:\ProgramData\pm2\service
PM2_INSTALL_DIRECTORY: C:\Users\Joseph\AppData\Roaming\npm\node_modules\pm2
Service User: NT AUTHORITY\LOCAL SERVICE
Attempting to create "C:\ProgramData\pm2\home"
Directory "C:\ProgramData\pm2\home" does not exist, creating it..
Attempting to create "C:\ProgramData\pm2\service"
Directory "C:\ProgramData\pm2\service" does not exist, creating it..
Copying service files from ".\src\windows\service\" to "C:\ProgramData\pm2\service"..
Copying files complete.
Attempting to grant "NT AUTHORITY\LOCAL SERVICE" full permissions to "C:\ProgramData\pm2\home".
Successfully set permissions on "C:\ProgramData\pm2\home".
Attempting to grant "NT AUTHORITY\LOCAL SERVICE" full permissions to "C:\ProgramData\pm2\service".
Successfully set permissions on "C:\ProgramData\pm2\service".
Running Node service install script..
service-management\install Installing
Installing service "PM2" at "C:\ProgramData\pm2\service"
service-management\install Complete
Attempting to grant "NT AUTHORITY\LOCAL SERVICE" full permissions to "C:\ProgramData\pm2\home".
Successfully set permissions on "C:\ProgramData\pm2\home".
Attempting to grant "NT AUTHORITY\LOCAL SERVICE" full permissions to "C:\ProgramData\pm2\service".
Successfully set permissions on "C:\ProgramData\pm2\service".
Updating "pm2.exe" service to run as "NT AUTHORITY\LocalService"
Attempt #2 to locate "pm2.exe" service..
Found "pm2.exe" service:
State: Stopped
Status: OK
Started: False
Start Mode: Auto
Service Type: Own Process
Start Name: LocalSystem
Changing service user account..
Starting service..
State is now: Start Pending
State is now: Stopped
State is now: Stopped
State is now: Stopped
I waited for 5mins or so and the service didn't get started, so I killed the setup.
Screenshot of the service if it's helpful
So I tried to run npm run configure
then run npm run setup
again. The result seem to be the same, the service doesn't seem to be able to get started.
Let me know if you want me to try anything out.
from pm2-installer.
Hi @bwgjoseph,
That shouldn't be a problem. I've bundled pm2-installer
on Windows 10 Pro and deployed on both Server 2019 and Server 2016 without issue.
Prior to installation, pm2-installer
uses bundle.json
to check the current environment against the one it was bundled with and prints out warnings if anything doesn't match. Those warnings can be safely ignored if everything works, but they can be helpful for debugging if not.
Feel free to reach out if you have any problems!
from pm2-installer.
Hey @jessety,
I have just tested on my local VM, and it seem to be working great except that I need to run the command npm run setup
as a administrator, otherwise, it won't work.
Exception calling "SetEnvironmentVariable" with "3" argument(s): "Requested registry access is not allowed."
At C:\Users\xxx\Desktop\pm2-installer-3.0.2\pm2-installer-3.0.2\src\windows\setup-service.ps1:13 char:3
+ [Environment]::SetEnvironmentVariable("PM2_HOME", $env:PM2_HOME, "M ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : SecurityException
-
I also noticed that
pm2.exe
service is in stopped mode after I installed it (even after I have restarted my machine). Do I have to start it manually? -
Where is
pm2-logrotate
supposed to be installed to? I couldn't find it underC:\ProgramData\pm2\home\modules
-
What's the reason for the need to run command prompt as administrator before I can run
pm2
command?
from pm2-installer.
Hi @bwgjoseph,
PM2 stores all the information it needs to run (dump of running processes, logs, modules, process ID of the daemon, etc.) in its "home" folder. On *nix systems, this is normally ~/.pm2/
. When the pm2
process starts, it checks the environmental variables for PM2_HOME
. If set, it uses that value as its home folder instead.
Because the service runs as the LocalService
user on Windows, pm2-installer
needs to set the PM2_HOME
environmental variable at a machine level before starting the service. When interacting with PM2, the command line interface loads the service process PID from the home folder, so if thePM2_HOME
variable isn't the same for both LocalService
and the user interacting with it, the CLI will assume no daemon is running and attempt to spawn one itself. Setting ENV values for the current user doesn't require admin privileges, but setting them on a "machine" level for all users does.
[Environment]::SetEnvironmentVariable("PM2_HOME", "C:\ProgramData\pm2\home\", "Machine")
If the above command fails, the rest of the installation will fail. The service should be automatically started- it should have printed out information about this during the setup process. You are correct, the pm2-logrotate
module should be in $env:PM2_HOME\modules
. If you attempted an install without elevated permissions and then ran it again as an admin, it might have borked itself. I suggest running npm run remove
before npm run setup
again in an Admin PowerShell window. If that doesn't work, post the setup
output here and I should be able to get a better idea of what's going on.
I re-read the README and I realize the requirement for elevated permissions was definitely not clear, so thanks for bringing this up!
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
- Failed to set permissions on "C:\ProgramData\pm2\home" HOT 7
- 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.