ddyakov
ddyakov

Reputation: 21

Strapi develop script not working with PM2

I am trying to run Strapi in development mode with pm2 by using this command:

pm2 start npm --name myprojectname -- run develop

Unfortunately, I get the following error

0|edtech-a | SyntaxError: Unexpected token ':'
0|edtech-a |     at wrapSafe (internal/modules/cjs/loader.js:979:16)
0|edtech-a |     at Module._compile (internal/modules/cjs/loader.js:1027:27)
0|edtech-a |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
0|edtech-a |     at Module.load (internal/modules/cjs/loader.js:928:32)
0|edtech-a |     at Function.Module._load (internal/modules/cjs/loader.js:769:14)
0|edtech-a |     at Object.<anonymous> (C:\Users\dimit\AppData\Roaming\npm\node_modules\pm2\lib\ProcessContainerFork.js:33:23)
0|edtech-a |     at Module._compile (internal/modules/cjs/loader.js:1063:30)
0|edtech-a |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
0|edtech-a |     at Module.load (internal/modules/cjs/loader.js:928:32)
0|edtech-a |     at Function.Module._load (internal/modules/cjs/loader.js:769:14)

I get the same error when I try to run Strapi in development mode through an ecosystem.config.json file as well.

Has somebody faced this issue, if yes, how can I solve it?

Upvotes: 2

Views: 3230

Answers (2)

Mikaels Slava
Mikaels Slava

Reputation: 186

Yeah, I encountered some problems myself and decided to go for a workaround:

Create a script with the commands you would type normally:

touch strapi.sh

Type in your desired commands:

nano strapi.sh

    cd my-strapi-project 
    npm run develop

Close and save (Crtl+x then type "y" and press enter).

Now just start that file with pm2

pm2 start strapi.sh

Check if everything works fine

pm2 logs

Thats it.

Upvotes: 2

Hasip Timurtas
Hasip Timurtas

Reputation: 980

Can you try with this:

pm2 start npm --name myprojectname --interpreter bash -- run develop

UPDATED

for yarn

pm2 start yarn --name myprojectname --interpreter bash -- run develop

Upvotes: 1

Related Questions