从拉出的github项目启动React App

Dav*_*vid 2 node.js npm reactjs

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

我在虚拟机上运行Ubuntu 16.04.3,我的节点版本是4.2.6。我尝试了sudo apt-get install --only-upgrade nodejs,但是它只是说我的节点版本已经是最新的。(我之所以这样做,是因为npm start给了我很多错误,并告诉我可能是因为我可能必须更新节点),但是我使用create-react-app创建的应用程序可以正常工作吗?错误: 在此处输入图片说明 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"
        }
}
Run Code Online (Sandbox Code Playgroud)

Sin*_*pcs 11

执行以下步骤:

//Step 1:
git clone [repository url]

//Step 2:
cd [local repository]
Run Code Online (Sandbox Code Playgroud)
//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"
  },
Run Code Online (Sandbox Code Playgroud)
//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
Run Code Online (Sandbox Code Playgroud)

注意:从某些存储库克隆yarnnpm之间可能会有一些冲突。最好假设每个回购在最终运行之前都需要进行修剪npm install。我在几种不同的因素下多次测试了上述步骤。这是我到目前为止最好的。