Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to start #53

Open
pdipietro opened this issue Sep 13, 2021 · 1 comment
Open

Unable to start #53

pdipietro opened this issue Sep 13, 2021 · 1 comment

Comments

@pdipietro
Copy link

Hi,
I tried to use your app, without success. It should be a matter of configuration I cannot get rid of.

I have a react application whose structure is as follow:

/src
/src/App.js
/src/index.js

The index.js file is as follow:

import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import reportWebVitals from './reportWebVitals';
import 'bootstrap/dist/css/bootstrap.min.css';
import { MemoryRouter } from 'react-router';

ReactDOM.render(
  <MemoryRouter>
    <App />
  </MemoryRouter>,
  document.getElementById('root')
);

The package.json is as follow:

{
  "name": "client",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@material-ui/core": "^4.12.3",
    "@material-ui/icons": "^4.11.2",
    "@testing-library/jest-dom": "^5.11.4",
    "@testing-library/react": "^11.1.0",
    "@testing-library/user-event": "^12.1.10",
    "axios": "^0.21.1",
    "bootstrap": "^5.1.0",
    "react": "^17.0.2",
    "react-bootstrap": "^2.0.0-beta.4",
    "react-dom": "^17.0.2",
    "react-icons": "^4.2.0",
    "react-router-dom": "^5.2.0",
    "react-scripts": "^4.0.3",
    "react-table": "^7.7.0",
    "web-vitals": "^1.0.1",
    "underscore": "^1.9.2"

  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
...

Usually, I start the application with npm start and it runs fine.

I config your app as follow:

APP_NAME="app"
USER="ubuntu"
GROUP="$USER"
NODE_ENV="development"
PORT="3000"
APP_DIR="/home/ubuntu/KebraContest"
NODE_APP="./src/index.js"
KWARGS=""
CONFIG_DIR="$APP_DIR"
PID_DIR="$APP_DIR/pid"
PID_FILE="$PID_DIR/$APP_NAME.pid"
LOG_DIR="$APP_DIR/log"
LOG_FILE="$LOG_DIR/$APP_NAME.log"
NODE_EXEC=$(which node)

I need to start with sudo, otherwise it doesn't run. This is the result:

sudo /etc/init.d/node-app start
Starting app ...
app started with pid 1096

The application doesn't respond on port 3000, and

sudo /etc/init.d/node-app status
app stopped, but pid file exists

the log reports:

cat log/app.log 
(node:1096) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/home/ubuntu/KebraContest/src/index.js:1
import React from 'react';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (internal/modules/cjs/loader.js:988:16)
    at Module._compile (internal/modules/cjs/loader.js:1036:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
    at internal/main/run_main_module.js:17:47

And this sound strange to me, because the app runs nicely when started manually.

Any suggestion, please?

Thank you

@mckaygerhard
Copy link

that is the result of using winbuntu.. you must import all the files using the unprivilegied account.. that means your nodejs assets files must be available to the non root user and also the project itselft..

then the script must change to the unpriivilegied user and run the application.. puff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants