我刚开始学习并发npm来React。
我想知道如何使用并发npm在Github页面上部署React项目。
通常在本地机器上,我们会使用服务器端package.json文件运行应用程序
“dev”:“并发”npm运行服务器“”npm运行客户端“”
在终端中>npm运行dev
我尝试用gh-pages npm在Github page上部署react应用程序,但用并发npm,
我不知道该怎么做,因为有两个package.json。
另外,我不太了解节点环境和npm运行构建。
服务器端package.json:
{
"name": "contact-keeper",
"version": "1.0.0",
"description": "Contact manager app",
"main": "server.js",
"homepage": "https://myprofile.github.io/Contact-Keeper-with-React",
"scripts": {
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
"start": "node server.js",
"server": "nodemon server.js",
"client": "npm start --prefix client",
"clientinstall": "npm install --prefix client",
"dev": "concurrently \"npm run server\" \"npm run client\""
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"bcryptjs": "^2.4.3",
"config": "^3.1.0",
"dotenv": "^8.0.0",
"express": "^4.17.1",
"express-validator": "^6.1.1",
"jsonwebtoken": "^8.5.1",
"mongoose": "^5.6.4"
},
"devDependencies": {
"concurrently": "^4.1.1",
"gh-pages": "^2.1.1",
"nodemon": "^1.19.1"
}
}
客户端服务器Package.json:
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"axios": "^0.19.0",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-router-dom": "^5.0.1",
"react-scripts": "3.0.1",
"react-transition-group": "^4.2.1",
"uuid": "^3.3.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"proxy": "http://localhost:5000"
}
是否有任何关于设置环境的文档或基础知识我需要学习更多来理解这个主题?
Github不(完全)是一个为其他用户提供工作应用程序的服务。Github是存储代码、更新代码和管理版本的存储库。
我认为,将应用程序“并发”部署到github意味着有一种方法可以使用新版本代码更新github,同时将其在线部署到一个服务(如Heroku)。
您应该研究和理解Git(与github相对)是什么,因为它对于开发是必不可少的。在尝试部署到Heroku、AWS等服务之前,先熟练地使用git管理应用程序代码...
编辑
正如Asaf Aviv所指出的,您可以使用Github页面为Github的前端应用程序提供服务,但您仍然需要能够将本地代码上推到Github才能工作。