Как пофиксить ошибку в pm2 при запуске файла node?

Пытаюсь запустить файл через
pm2 start index.js
В логах выдает вот такую вот ошибку
ex          |     at internal/main/run_main_module.js:17:47 {
3|index          |   code: 'ERR_REQUIRE_ESM'
3|index          | }
PM2              | App [index:3] exited with code [1] via signal [SIGINT]
PM2              | App [index:3] starting in -fork mode-
PM2              | App [index:3] online
3|index          | Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/apps/addDealInAmo_kedr/index.js
3|index          |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1015:13)
3|index          |     at Module.load (internal/modules/cjs/loader.js:863:32)
3|index          |     at Function.Module._load (internal/modules/cjs/loader.js:708:14)
3|index          |     at Object.<anonymous> (/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23)
3|index          |     at Module._compile (internal/modules/cjs/loader.js:999:30)
3|index          |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
3|index          |     at Module.load (internal/modules/cjs/loader.js:863:32)
3|index          |     at Function.Module._load (internal/modules/cjs/loader.js:708:14)
3|index          |     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
3|index          |     at internal/main/run_main_module.js:17:47 {
3|index          |   code: 'ERR_REQUIRE_ESM'
3|index          | }
PM2              | App [index:3] exited with code [1] via signal [SIGINT]
PM2              | App [index:3] starting in -fork mode-
PM2              | App [index:3] online
3|index          | Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/apps/addDealInAmo_kedr/index.js
3|index          |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1015:13)
3|index          |     at Module.load (internal/modules/cjs/loader.js:863:32)
3|index          |     at Function.Module._load (internal/modules/cjs/loader.js:708:14)
3|index          |     at Object.<anonymous> (/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23)
3|index          |     at Module._compile (internal/modules/cjs/loader.js:999:30)
3|index          |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
3|index          |     at Module.load (internal/modules/cjs/loader.js:863:32)
3|index          |     at Function.Module._load (internal/modules/cjs/loader.js:708:14)
3|index          |     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
3|index          |     at internal/main/run_main_module.js:17:47 {
3|index          |   code: 'ERR_REQUIRE_ESM'
3|index          | }
PM2              | App [index:3] exited with code [1] via signal [SIGINT]
PM2              | App [index:3] starting in -fork mode-
PM2              | App [index:3] online
3|index          | Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/apps/addDealInAmo_kedr/index.js
3|index          |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1015:13)
3|index          |     at Module.load (internal/modules/cjs/loader.js:863:32)
3|index          |     at Function.Module._load (internal/modules/cjs/loader.js:708:14)
3|index          |     at Object.<anonymous> (/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23)
3|index          |     at Module._compile (internal/modules/cjs/loader.js:999:30)
3|index          |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
3|index          |     at Module.load (internal/modules/cjs/loader.js:863:32)
3|index          |     at Function.Module._load (internal/modules/cjs/loader.js:708:14)
3|index          |     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
3|index          |     at internal/main/run_main_module.js:17:47 {
3|index          |   code: 'ERR_REQUIRE_ESM'
3|index          | }
PM2              | App [index:3] exited with code [1] via signal [SIGINT]
PM2              | App [index:3] starting in -fork mode-
PM2              | App [index:3] online
3|index          | Error [ERR_REQUIRE_ESM]: Must u

se import to load ES Module: /home/apps/addDealInAmo_kedr/index.js
3|index          |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1015:13)
3|index          |     at Module.load (internal/modules/cjs/loader.js:863:32)
3|index          |     at Function.Module._load (internal/modules/cjs/loader.js:708:14)
3|index          |     at Object.<anonymous> (/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23)
3|index          |     at Module._compile (internal/modules/cjs/loader.js:999:30)
3|index          |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
3|index          |     at Module.load (internal/modules/cjs/loader.js:863:32)
3|index          |     at Function.Module._load (internal/modules/cjs/loader.js:708:14)
3|index          |     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
3|index          |     at internal/main/run_main_module.js:17:47 {
3|index          |   code: 'ERR_REQUIRE_ESM'
3|index          | }
PM2              | App [index:3] exited with code [1] via signal [SIGINT]
PM2              | App [index:3] starting in -fork mode-
PM2              | App [index:3] online
3|index          | Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/apps/addDealInAmo_kedr/index.js
3|index          |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1015:13)
3|index          |     at Module.load (internal/modules/cjs/loader.js:863:32)
3|index          |     at Function.Module._load (internal/modules/cjs/loader.js:708:14)
3|index          |     at Object.<anonymous> (/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23)
3|index          |     at Module._compile (internal/modules/cjs/loader.js:999:30)
3|index          |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
3|index          |     at Module.load (internal/modules/cjs/loader.js:863:32)
3|index          |     at Function.Module._load (internal/modules/cjs/loader.js:708:14)
3|index          |     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
3|index          |     at internal/main/run_main_module.js:17:47 {
3|index          |   code: 'ERR_REQUIRE_ESM'
3|index          | }
PM2              | App [index:3] exited with code [1] via signal [SIGINT]
PM2              | App [index:3] starting in -fork mode-
PM2              | App [index:3] online
3|index          | Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/apps/addDealInAmo_kedr/index.js
3|index          |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1015:13)
3|index          |     at Module.load (internal/modules/cjs/loader.js:863:32)
3|index          |     at Function.Module._load (internal/modules/cjs/loader.js:708:14)
3|index          |     at Object.<anonymous> (/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23)
3|index          |     at Module._compile (internal/modules/cjs/loader.js:999:30)
3|index          |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
3|index          |     at Module.load (internal/modules/cjs/loader.js:863:32)
3|index          |     at Function.Module._load (internal/modules/cjs/loader.js:708:14)
3|index          |     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
3|index          |     at internal/main/run_main_module.js:17:47 {
3|index          |   code: 'ERR_REQUIRE_ESM'
3|index          | }
PM2              | App [index:3] exited with code [1] via signal [SIGINT]
PM2              | Script /home/apps/addDealInAmo_kedr/index.js had too many unstable restarts (16). Stopped. "errored"


Хотя если запускать на прямую node index.js все работает нормально, в чем может быть проблема?
  • Вопрос задан
  • 383 просмотра
Пригласить эксперта
Ответы на вопрос 1
@Zerg89
Имеющий глаза да увидит
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/apps/addDealInAmo_kedr/index.js

Скорее всего нехватает какого-то модуля или он его не там ищет или проблема с правами доступа к модулю
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы