Getting error Cannot use import statement outside a module when using pm2

Viewed 25

Hello i am running Ubuntu server on "digitalocean" but getting error when trying to run my app using pm2 start App.js at first it shows as its online but ones you pm2 list its says errored and in the logs you can see error /var/www/project/src/index.js:1 0|src | import React from 'react'; 0|src | ^^^^^^ 0|src | 0|src | SyntaxError: Cannot use import statement outside a module 0|src | at wrapSafe (internal/modules/cjs/loader.js:1001:16) 0|src | at Module._compile (internal/modules/cjs/loader.js:1049:27) 0|src | at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10) 0|src | at Module.load (internal/modules/cjs/loader.js:950:32) 0|src | at Function.Module._load (internal/modules/cjs/loader.js:790:12) 0|src | at Object.<anonymous> (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23) 0|src | at Module._compile (internal/modules/cjs/loader.js:1085:14) 0|src | at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10) 0|src | at Module.load (internal/modules/cjs/loader.js:950:32) 0|src | at Function.Module._load (internal/modules/cjs/loader.js:790:12)

0 Answers
Related