Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Starting React App from pulled github project

I've pulled a github repository containing code for a reactjs app into one of my directories but I can't find a way to run the app on my computer. I can start a new app using create-react-app but I can't/(don't know how to) use the existing app for instead ofa freshly created one.

I'm running Ubuntu 16.04.3 on a virtual machine, my node version is 4.2.6. I've tried sudo apt-get install --only-upgrade nodejs but it simply says my node version is already up to date. (I include this because npm start gives me a bunch of errors and tells me that it may be because I might have to update node) but the app I create with create-react-app works fine? The error: enter image description here Package.json:

{
    "name": "my-app",
    "version": "0.1.0",
    "private": true,
    "dependencies": {
        "bootstrap": "^3.3.7",
        "express": "^4.16.2",
        "package.json": "^2.0.1",
        "prop-types": "^15.6.0",
        "react": "^16.0.0",
        "react-bootstrap": "^0.31.5",
        "react-dom": "^16.0.0",
        "react-router-dom": "^4.2.2",
        "react-scripts": "1.0.14",
        "uuid": "^3.1.0",
        "webpack": "^3.8.1"
        },
    "scripts": {
        "start": "react-scripts start",
        "build": "react-scripts build",
        "test": "react-scripts test --env=jsdom",
        "eject": "react-scripts eject"
        },
    "devDependencies": {
        "babel-cli": "^6.26.0",
        "babel-preset-env": "^1.6.1"
        }
}
like image 657
David Avatar asked Nov 06 '17 12:11

David


1 Answers

Carry out the following steps:

//Step 1:
git clone [repository url]

//Step 2:
cd [local repository]
//Step 3:
//Check package.json file and ensure scripts are notated as below:

"scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
//Step 4: 
/* Delete the node_modules folder and any 'lock' files such as 
yarn.lock or package-lock.json if present.*/

//Step 5: 
npm install

//Step 6:
npm start

To Note: There can be some conflict between yarn and npm when cloning from certain repositories. It's best to assume that every repo may need trimming before ultimately running npm install. I tested the above steps several times under several different factors. This is the best I have so far.

like image 122
Sinapcs Avatar answered Sep 20 '22 16:09

Sinapcs