Unitech / Unitech/pm2

Error "Script not found" when running `pm2 start npm -- start`

Open
#4,811 18 comments 18 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
43.3k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

What's going wrong?

When trying to run a Next.js based site via PM2 through an npm script, the error above is thrown. See output below:

PS C:\Users\Me\Desktop\MyApp> pm2 start npm --name "app" -- start
[PM2] Starting C:\PROGRAM FILES\NODEJS\NPM.CMD in fork_mode (1 instance)               
[PM2] Done.
[PM2][ERROR] Script not found: C:\Users\Me\Desktop\MyApp\start

How could we reproduce this issue?

package.json

{
    "scripts": {
        "start": "next build && next start -p $PORT"
    },
}

Command:
pm2 start npm --name "app" -- start

Supporting information

OS: Windows 10
NPM Path:

C:\Program Files\nodejs\npm                                                            
C:\Program Files\nodejs\npm.cmd                                                        
C:\Users\Me\AppData\Roaming\npm\npm
C:\Users\Me\AppData\Roaming\npm\npm.cmd

report.txt

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue on Windows 10 with the supplied package.json and pm2 start npm --name "app" -- start command. Start by tracing how PM2 resolves npm.cmd and forwards the start argument, using report.txt and the reported npm paths as evidence. Done means the command starts the npm script without a "Script not found" error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, next.js, nodejs
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.