0

Here's my package.json

  "name": "airbnb",
  "version": "1.0.0",
  "description": "This is for my Project 2",
  "main": "index.js",
  "scripts": {
    "test": "None",
    "start": "node ./src/index.js"
  },
  "repository": {
    "type": "git",
    "url": ""
  },
  "keywords": [
    "ReactJS",
    "ESLINT",
    "Prettier",
    "yapf"
  ],
  "author": "",
  "license": "ISC",
  "bugs": {
    "url": ""
  },
  "homepage": "",
  "devDependencies": {
    "eslint": "^7.22.0",
    "eslint-config-airbnb": "^18.2.1",
    "eslint-plugin-import": "^2.22.1",
    "eslint-plugin-jsx-a11y": "^6.4.1",
    "eslint-plugin-react": "^7.22.0",
    "eslint-plugin-react-hooks": "^4.2.0",
    "webpack-cli": "^4.5.0"
  },
  "dependencies": {
    "react": "^17.0.1",
    "socket.io-client": "^4.0.0"
  }
}

And here's the error:

> airbnb@1.0.0 start /home/ec2-user/environment/flask_react_app/react-starter
> node ./src/index.js

/home/ec2-user/environment/flask_react_app/react-starter/src/index.js:1
import React from "react";
       ^^^^^

SyntaxError: Unexpected identifier
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! airbnb@1.0.0 start: `node ./src/index.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the airbnb@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ec2-user/.npm/_logs/2021-03-13T15_44_38_370Z-debug.log

I don't know why I'm getting this error. Is my script wrong? Is there another issue? If I remove node, I get a permission denied error. I'm unsure if I'm supposed to have node there. I'm pretty sure I am though, and I'm feeling really lost here. What options do I have?

1 Answers1

0

I had the same issue a while ago and I cannot 100% remember how I got rid of it but I recommend:

  1. npm install (maybe npm run setup) before npm start
  2. make sure you're in the correct folder when you run npm start
  • I get this message when I run npm install, and npm run start still gives me the same error: npm WARN @webpack-cli/configtest@1.0.1 requires a peer of webpack@4.x.x || 5.x.x but none is installed. You must install peer dependencies yourself. npm WARN webpack-cli@4.5.0 requires a peer of webpack@4.x.x || 5.x.x but none is installed. You must install peer dependencies yourself. added 16 packages from 15 contributors, removed 1 package and audited 272 packages in 2.954s 45 packages are looking for funding run `npm fund` for details found 0 vulnerabilities – In Doing It Mar 13 '21 at 16:27
  • Look at the top comment. I can remember I did these steps and it worked for me: https://stackoverflow.com/questions/42308879/how-to-solve-npm-error-npm-err-code-elifecycle – Simon Thomas Mar 13 '21 at 16:29
  • Followed all those steps exactly and I still get the same errors. – In Doing It Mar 13 '21 at 16:35
  • Say I remove node ./index.js and replace it with npm run start. The problem is now it just keeps running npm run start nonstop – In Doing It Mar 13 '21 at 16:38