React/Node deployment on Netlify



我最近部署了一个应用程序来heroku.但是我想知道如何将相同的应用程序部署到Netlify

我创建了一个在 Heroku 中运行良好的脚本:

"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix 
client && npm run build --prefix client".

我添加了与Heroku相同的全局变量,并且我也运行相同的脚本,但出现此错误:

2:34:44 PM: Error running command: Build script returned non-zero exit 
code: 127
2:34:44 PM: Failing build: Failed to build site
2:34:44 PM: failed during stage 'building site': Build script returned 
non-zero exit code: 127
2:34:44 PM: Finished processing build request in 25.404662076s

客户端包.json

{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"axios": "^0.18.0",
"classnames": "^2.2.5",
"jwt-decode": "^2.2.0",
"moment": "^2.22.0",
"react": "^16.3.1",
"react-dom": "^16.3.1",
"react-moment": "^0.7.0",
"react-redux": "^5.0.7",
"react-router-dom": "^4.2.2",
"react-scripts": "1.1.4",
"redux": "^3.7.2",
"redux-thunk": "^2.2.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"proxy": "http://localhost:5000"
}

服务器包.json

{
"name": "devconnector",
"version": "1.0.0",
"description": "Social network for developers",
"main": "server.js",
"scripts": {
"client-install": "npm install --prefix client",
"start": "node server.js",
"server": "nodemon server.js",
"client": "npm start --prefix client",
"dev": "concurrently "npm run server" "npm run client"",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install -- 
prefix client && npm run build --prefix client"
},
"author": "Brad Traversy",
"license": "MIT",
"dependencies": {
"bcryptjs": "^2.4.3",
"body-parser": "^1.18.2",
"concurrently": "^3.5.1",
"express": "^4.16.3",
"gravatar": "^1.6.0",
"jsonwebtoken": "^8.2.0",
"mongoose": "^5.0.12",
"netlify-cli": "^1.2.3",
"passport": "^0.4.0",
"passport-jwt": "^4.0.0",
"validator": "^9.4.1"
},
"devDependencies": {
"nodemon": "^1.17.3"
}
}

Netlify 在尝试部署后端时并不像 Heroku 那么简单。基本答案,你不能。

https://www.netlify.com/docs/functions/有一种方法可以使其工作,请参阅上面的链接,但我不知道该怎么做。

相关内容

  • 没有找到相关文章

最新更新