从拉取的 github 项目启动 React App [英] Starting React App from pulled github project

查看:40
本文介绍了从拉取的 github 项目启动 React App的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将包含 reactjs 应用程序代码的 github 存储库拉入我的一个目录中,但我找不到在我的计算机上运行该应用程序的方法.我可以使用 create-react-app 启动一个新应用程序,但我不能/(不知道如何)使用现有应用程序代替新创建的应用程序.

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.

我在虚拟机上运行 Ubuntu 16.04.3,我的节点版本是 4.2.6.我试过 sudo apt-get install --only-upgrade nodejs 但它只是说我的节点版本已经是最新的.(我包含这个是因为 npm start 给了我一堆错误,并告诉我这可能是因为我可能需要更新节点)但是我用 create-react-app 创建的应用程序工作正常吗?错误:包.json:

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: 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"
        }
}

推荐答案

执行以下步骤:

//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

要注意:从某些存储库克隆时,yarnnpm 之间可能存在一些冲突.最好假设每个 repo 在最终运行 npm install 之前可能需要修剪.我在几个不同的因素下多次测试了上述步骤.这是我迄今为止最好的.

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.

这篇关于从拉取的 github 项目启动 React App的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆