Reactjs Heroku中的部署/节点应用程序失败
我想不出是怎么回事,请帮忙 ----->检测到Node.js应用程序 ----->创建运行时环境 NPM_配置_日志级别=错误 NODE\u VERBOSE=false 节点_ENV=生产 节点\模块\缓存=真 ----->安装二进制文件 engines.node(package.json):未指定 engines.npm(package.json):未指定(使用默认值) 正在解析节点版本8.x。。。 正在下载和安装节点8.11.4。。。 使用默认npm版本:5.6.0 ----->恢复缓存 正在从缓存目录加载2(默认):Reactjs Heroku中的部署/节点应用程序失败,reactjs,heroku,deployment,Reactjs,Heroku,Deployment,我想不出是怎么回事,请帮忙 ----->检测到Node.js应用程序 ----->创建运行时环境 NPM_配置_日志级别=错误 NODE\u VERBOSE=false 节点_ENV=生产 节点\模块\缓存=真 ----->安装二进制文件 engines.node(package.json):未指定 engines.npm(package.json):未指定(使用默认值) 正在解析节点版本8.x。。。 正在下载和安装节点8.11.4。。。 使用默认npm版本:5.6.0 ----->恢复缓存 正
- 节点单元
- bower_组件(未缓存-跳过) ----->构建依赖项 安装节点模块(package.json+包锁) 5.321s中的最新版本 ----->缓存生成 清除以前的节点缓存 保存2个缓存目录(默认):
- 节点单元
- bower_组件(无需缓存) ----->修剪依赖性 跳过,因为npm 5.6.0在运行“npm prune”时,由于已知问题有时会失败 您可以通过更新package.json中的至少npm 5.7.1来消除此警告 ----->建造成功! ----->发现进程类型 Procfile声明类型->(无) buildpack->web的默认类型 ----->压缩。。。 完成:3390万 ----->发射。。。 发布v36 部署到Heroku
{
"name": "github-fetcher-fullstack-v2",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"react-dev": "webpack -d --watch",
"start": "nodemon server/index.js"
},
"license": "ISC",
"devDependencies": {
"babel-core": "^6.23.1",
"babel-loader": "^6.3.2",
"babel-preset-es2015": "^6.22.0",
"babel-preset-react": "^6.23.0",
"webpack": "^2.2.1"
},
"dependencies": {
"angular": "^1.6.3",
"animate.css": "^3.7.0",
"bluebird": "^3.5.1",
"body-parser": "^1.17.2",
"bootstrap": "^4.1.3",
"express": "^4.15.0",
"jquery": "^3.1.1",
"moment": "^2.22.2",
"mongoose": "^4.8.6",
"mysql": "^2.13.0",
"popper.js": "^1.14.4",
"react": "^15.4.2",
"react-animated-css": "^1.0.4",
"react-dom": "^15.4.2",
"react-router-dom": "^4.3.1",
"react-simple-popover": "^0.2.4",
"request": "^2.88.0",
"unirest": "^0.5.1"
}
}
{
"name": "github-fetcher-fullstack-v2",
...
//starts here
"engines": {
"node": "10.x"
"npm": ""
}
//ends here
您可以使用
express.js
在heroku下轻松运行项目。您的所有依赖项必须位于依赖项下
package.json
"scripts": {
"build": "Add yours",
"postinstall": "Same with build",
"start": "node server.js" // Heroku looks for this
},
"dependencies": {
Add all your dependencies here
}
在根目录下创建server.js文件
//Install express server
const express = require('express');
const path = require('path');
const app = express();
// Your dist folder
app.use(express.static(__dirname + '/react-client/dist/'));
app.get('/*', function(req,res) {
res.sendFile(path.join(__dirname+'/react-client/dist/index.html'));
});
// Start the app by listening on the default Heroku port
app.listen(process.env.PORT || 8080);
SynonymFinder.js
.header("X-Mashape-Key", process.env.SYNONYMKEY) // You can use Environment Variables for API Key
将API密钥添加到Heroku项目设置下的配置变量中尝试将
引擎中的节点和npm版本指定为对象
package.json:
{
"name": "github-fetcher-fullstack-v2",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"react-dev": "webpack -d --watch",
"start": "nodemon server/index.js"
},
"license": "ISC",
"devDependencies": {
"babel-core": "^6.23.1",
"babel-loader": "^6.3.2",
"babel-preset-es2015": "^6.22.0",
"babel-preset-react": "^6.23.0",
"webpack": "^2.2.1"
},
"dependencies": {
"angular": "^1.6.3",
"animate.css": "^3.7.0",
"bluebird": "^3.5.1",
"body-parser": "^1.17.2",
"bootstrap": "^4.1.3",
"express": "^4.15.0",
"jquery": "^3.1.1",
"moment": "^2.22.2",
"mongoose": "^4.8.6",
"mysql": "^2.13.0",
"popper.js": "^1.14.4",
"react": "^15.4.2",
"react-animated-css": "^1.0.4",
"react-dom": "^15.4.2",
"react-router-dom": "^4.3.1",
"react-simple-popover": "^0.2.4",
"request": "^2.88.0",
"unirest": "^0.5.1"
}
}
{
"name": "github-fetcher-fullstack-v2",
...
//starts here
"engines": {
"node": "10.x"
"npm": ""
}
//ends here
如果您的站点是静态的,您可能还需要一个服务器,请查看您可以共享您的repo url吗?:)抱歉,我正在睡觉,我收到了错误:找不到模块'/keys/config.js'
,您已将config.js
添加到.gitIgnors