gpt4 book ai didi

node.js - Netlify 上的 React/Node 部署

转载 作者:太空宇宙 更新时间:2023-11-04 01:44:42 24 4
gpt4 key购买 nike

我最近向 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/有一种方法可以使其工作,请参阅上面的链接,但我不知道该怎么做。

关于node.js - Netlify 上的 React/Node 部署,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51902639/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com