nodejs / help

:sparkles: Need help with Node.js? File an Issue here. :rocket:
1.47k stars 280 forks source link

I have deployed my Reactjs application on AWS EC2 instance, I am getting this error #4245

Closed noor-softversum closed 4 months ago

noor-softversum commented 1 year ago

Details

PM2        | 2023-09-18T07:08:18: PM2 log: App [index:1] online
PM2        | 2023-09-18T07:08:18: PM2 log: App [index:1] exited with code [1] via signal [SIGINT]
PM2        | 2023-09-18T07:08:18: PM2 log: App [index:1] starting in -fork mode-
PM2        | 2023-09-18T07:08:18: PM2 log: App [index:1] online
PM2        | 2023-09-18T07:08:18: PM2 log: App [index:1] exited with code [1] via signal [SIGINT]
PM2        | 2023-09-18T07:08:18: PM2 log: App [index:1] starting in -fork mode-
PM2        | 2023-09-18T07:08:18: PM2 log: App [index:1] online
PM2        | 2023-09-18T07:08:18: PM2 log: App [index:1] exited with code [1] via signal [SIGINT]
PM2        | 2023-09-18T07:08:18: PM2 log: App [index:1] starting in -fork mode-
PM2        | 2023-09-18T07:08:18: PM2 log: App [index:1] online
PM2        | 2023-09-18T07:08:18: PM2 log: App [index:1] exited with code [1] via signal [SIGINT]
PM2        | 2023-09-18T07:08:18: PM2 log: App [index:1] starting in -fork mode-
PM2        | 2023-09-18T07:08:18: PM2 log: App [index:1] online
PM2        | 2023-09-18T07:08:19: PM2 log: App [index:1] exited with code [1] via signal [SIGINT]
PM2        | 2023-09-18T07:08:19: PM2 log: Script /home/ubuntu/smartBusinessCard/frontend/src/index.js had too many unstable restarts (16). Stopped. "errored"

/home/ubuntu/.pm2/logs/index-out.log last 15 lines:
0|index    | path:  [Function: serveStatic]
0|index    | Connected to MongoDB
0|index    | Server is running on port 5000
0|index    | Connected to MongoDB
0|index    | Server is running on port 5000
0|index    | Connected to MongoDB
0|index    | Server is running on port 5000
0|index    | Connected to MongoDB
0|index    | Server is running on port 5000

/home/ubuntu/.pm2/logs/index-error.log last 15 lines:
0|index    | /home/ubuntu/smartBusinessCard/frontend/src/index.js:1
0|index    | import React from 'react';
0|index    | ^^^^^^
0|index    | 
0|index    | SyntaxError: Cannot use import statement outside a module
0|index    |     at Object.compileFunction (node:vm:360:18)
0|index    |     at wrapSafe (node:internal/modules/cjs/loader:1124:15)
0|index    |     at Module._compile (node:internal/modules/cjs/loader:1160:27)
0|index    |     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1250:10)
0|index    |     at Module.load (node:internal/modules/cjs/loader:1074:32)
0|index    |     at Function.Module._load (node:internal/modules/cjs/loader:909:12)
0|index    |     at Object.<anonymous> (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23)
0|index    |     at Module._compile (node:internal/modules/cjs/loader:1196:14)
0|index    |     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1250:10)
0|index    |     at Module.load (node:internal/modules/cjs/loader:1074:32)

Node.js version

v16.20.0

Example code

No response

Operating system

Ubuntu

Scope

I have applied every single thing. Like uninstalled node_modules and then installed it again and again, I don't know why this issue is coming

Module and version

Not applicable.

preveen-stack commented 1 year ago

home/ubuntu/.pm2/logs/index-error.log last 15 lines: 0|index | /home/ubuntu/smartBusinessCard/frontend/src/index.js:1 0|index | import React from 'react'; 0|index | ^^^^^^ 0|index | 0|index | 0|index | SyntaxError: Cannot use import statement outside a module

ref: https://nodejs.org/api/esm.html https://stackoverflow.com/questions/58211880/uncaught-syntaxerror-cannot-use-import-statement-outside-a-module-when-import

ljharb commented 1 year ago

Name the file .mjs so it's treated as ESM.

github-actions[bot] commented 5 months ago

It seems there has been no activity on this issue for a while, and it is being closed in 30 days. If you believe this issue should remain open, please leave a comment. If you need further assistance or have questions, you can also search for similar issues on Stack Overflow. Make sure to look at the README file for the most updated links.

github-actions[bot] commented 4 months ago

It seems there has been no activity on this issue for a while, and it is being closed. If you believe this issue should remain open, please leave a comment. If you need further assistance or have questions, you can also search for similar issues on Stack Overflow. Make sure to look at the README file for the most updated links.