S
S
Sergey2019-12-08 02:19:28
Node.js
Sergey, 2019-12-08 02:19:28

PM2 NODEJS error how to fix?

Started learning NODEJS, installed nodejs package in Ubuntu. I launched a test file hello.js in the terminal, launching an http server with the output Hello Word (node ​​/usr/share/nginx/node/hello.js) - everything works.
Now, as I understand it, in order to start the server without blocking the terminal, you need PM2. Installed.
However, any pm2 commands simply or pm2 start /usr/share/nginx/node/hello.js
gives an error:

/usr/local/lib/node_modules/pm2/node_modules/debug/src/node.js:132
        let val = process.env[key];
        ^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:374:25)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/pm2/node_modules/debug/src/index.js:9:19)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)

How to fix and what kind of error is this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
2
2CHEVSKII, 2019-12-08
@goodwin74

You have an old node installed, the eighth one is in the default repository.
Here's how to install a new one

E
EchoStan, 2019-12-08
@EchoStan

Also, to unhook the node from the terminal, an ampersand at the end of the command is enough, node ххх.js &
pm2 is "from a cannon to sparrows". But restarts, turns logs, yes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question