Home > Mobile >  SyntaxError: Unexpected identifier 'pipefail'
SyntaxError: Unexpected identifier 'pipefail'

Time:11-18

I am having this issue when I try to deploy NodeJS app (built with NextJS) using pm2. I follow the instruction described here.

My attempt to execute pm2 start command seemed working, as shown by the snippet below.

┌────┬────────────────────┬──────────┬──────┬───────────┬──────────┬──────────┐ │ id │ name │ mode │ ↺ │ status │ cpu │ memory │ ├────┼────────────────────┼──────────┼──────┼───────────┼──────────┼──────────┤ │ 0 │ experti │ fork │ 0 │ online │ 0% │ 25.7mb │ └────┴────────────────────┴──────────┴──────┴───────────┴──────────┴──────────┘

But when I run pm2 list, the previous execution turned out to be error. ┌────┬────────────────────┬──────────┬──────┬───────────┬──────────┬──────────┐ │ id │ name │ mode │ ↺ │ status │ cpu │ memory │ ├────┼────────────────────┼──────────┼──────┼───────────┼──────────┼──────────┤ │ 0 │ process │ fork │ 15 │ errored │ 0% │ 0b │ └────┴────────────────────┴──────────┴──────┴───────────┴──────────┴──────────┘

I checked the pm2 logs as described by this answer and it led me to this log: `

SyntaxError: Unexpected identifier 'pipefail'
    at Object.compileFunction (node:vm:360:18)
    at wrapSafe (node:internal/modules/cjs/loader:1088:15)
    at Module._compile (node:internal/modules/cjs/loader:1123:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at Object.<anonymous> (/home/equitica/.npm/_npx/5f7878ce38f1eb13/node_modules/pm2/lib/ProcessContainerFork.js:33:23)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
/home/<username>/.asdf/plugins/nodejs/shims/npm:4
set -o pipefail
       ^^^^^^^^

`

So, I checked the file that specified by the log, and found this line (shown below):

#! /usr/bin/env bash
set -eu
set -o pipefail <-- this line is probably the problem

I have no idea what the line means, and have no clue to solve the problem.

CodePudding user response:

I solved this issue by removing the /home/<username>/.asdf/plugins/nodejs/shims/npm file and then execute pm2 start npm --name <process> -- run start.

  • Related