我已按照说明操作,但它仍无法正常工作。我的存储库是这样的: https://github.com/diegoarcega/learning_react
Procfile
web: node index.js
index.js
var cool = require('cool-ascii-faces');
var express = require('express');
var path = require('path');
var app = express();
var DIST_DIR = path.resolve(__dirname + '/../dist');
app.set('port', (process.env.PORT || 5000));
app.use('/assets/', express.static(DIST_DIR + '/assets'));
app.get('/', function(req, res) {
res.send('hello');
});
app.get('/cool', function(request, response) {
response.send(cool());
});
app.listen(app.get('port'), function() {
console.log('Listening port ' + app.get('port'))
});
的package.json
{
"name": "learning_react",
"version": "0.0.1",
"description": "practising react",
"main": "index.js",
"scripts": {
"kill": "fuser -k 30000/tcp",
"start": "node index.js",
"serve": "node index.js",
"dev": "NODE_ENV=development babel-node server/server.js",
"test": "echo \"Error: no test specified\" && exit 1",
"clean": "rimraf dist/ ",
"copy": "copyfiles -f src/index.html src/favicon.ico dist",
"prod": "npm run clean && webpack --config webpack.config.dist.js -p && npm run copy",
"dist": "NODE_ENV=production babel-node server/server.js ",
"deploy": "surge --project ./dist --domain diegoarcega-react.surge.sh"
},
"repository": {
"type": "git",
"url": "https://github.com/diegoarcega/learning_react"
},
"keywords": [
"REACT"
],
"engines": {
"node": "4.4.5",
"npm": "3.9.6"
},
"author": "Diego Arcega",
"license": "BSD-2-Clause",
"bugs": {
"url": "https://github.com/diegoarcega/learning_react/issues"
},
"dependencies": {
"axios": "^0.12.0",
"babel-polyfill": "^6.9.1",
"cool-ascii-faces": "^1.3.4",
"firebase": "^3.0.5",
"material-ui": "^0.15.1",
"muicss": "^0.6.5",
"q": "^1.4.1",
"react": "~15.1.0",
"react-dom": "~15.1.0",
"react-redux": "~4.4.5",
"react-router": "~2.4.1",
"react-tap-event-plugin": "^1.0.0",
"redux": "~3.5.2",
"redux-thunk": "^2.1.0"
},
"devDependencies": {
"babel-cli": "^6.10.1",
"babel-core": "~6.9.1",
"babel-loader": "~6.2.4",
"babel-plugin-transform-es2015-function-name": "^6.9.0",
"babel-plugin-transform-es2015-literals": "^6.8.0",
"babel-plugin-transform-es2015-template-literals": "^6.8.0",
"babel-plugin-transform-runtime": "^6.9.0",
"babel-preset-es2015": "~6.9.0",
"babel-preset-react": "~6.5.0",
"babel-preset-react-hmre": "^1.1.1",
"babel-preset-react-optimize": "^1.0.1",
"copyfiles": "^1.0.0",
"css-loader": "^0.23.1",
"express": "~4.13.4",
"file-loader": "^0.8.5",
"object-assign": "^4.1.0",
"react-css-modules": "^3.7.6",
"react-tap-event-plugin": "^1.0.0",
"react-thunk": "^1.0.0",
"style-loader": "^0.13.1",
"url-loader": "^0.5.7",
"webpack": "~1.13.1",
"webpack-dev-middleware": "^1.6.1",
"webpack-dev-server": "^1.14.1",
"webpack-hot-middleware": "^2.10.0"
}
}
我只是想让它先发挥作用。错误日志是这样的:
2016-07-06T17:00:56.197239+00:00 heroku[web.1]: State changed from crashed to starting
2016-07-06T17:01:00.211013+00:00 heroku[web.1]: Starting process with command `node index.js`
2016-07-06T17:01:01.580923+00:00 app[web.1]: module.js:327
2016-07-06T17:00:54.456548+00:00 heroku[api]: Deploy 23f2e63 by diegoarcega@gmail.com
2016-07-06T17:01:01.580940+00:00 app[web.1]: at Object.<anonymous> (/app/index.js:2:15)
2016-07-06T17:01:01.580940+00:00 app[web.1]: at Module._compile (module.js:409:26)
2016-07-06T17:01:02.228107+00:00 heroku[web.1]: State changed from starting to crashed
2016-07-06T17:01:02.212126+00:00 heroku[web.1]: Process exited with status 1
2016-07-06T17:01:01.580941+00:00 app[web.1]: at Function.Module._load (module.js:300:12)
2016-07-06T17:01:01.580942+00:00 app[web.1]: at Function.Module.runMain (module.js:441:10)
2016-07-06T17:01:01.580939+00:00 app[web.1]: at Function.Module._load (module.js:276:25)
2016-07-06T17:01:01.580939+00:00 app[web.1]: at Module.require (module.js:353:17)
2016-07-06T17:01:01.580940+00:00 app[web.1]: at require (internal/module.js:12:17)
2016-07-06T17:01:01.580940+00:00 app[web.1]: at Object.<anonymous> (/app/index.js:2:15)
2016-07-06T17:01:01.580940+00:00 app[web.1]: at Module._compile (module.js:409:26)
2016-07-06T17:01:01.580941+00:00 app[web.1]: at Object.Module._extensions..js (module.js:416:10)
2016-07-06T17:01:02.228107+00:00 heroku[web.1]: State changed from starting to crashed
2016-07-06T17:01:02.212126+00:00 heroku[web.1]: Process exited with status 1
2016-07-06T17:02:12.435185+00:00 heroku[slug-compiler]: Slug compilation started
2016-07-06T17:02:12.435194+00:00 heroku[slug-compiler]: Slug compilation finished
2016-07-06T17:02:12.782559+00:00 heroku[web.1]: State changed from crashed to starting
2016-07-06T17:02:17.345331+00:00 heroku[web.1]: Starting process with command `node index.js`
2016-07-06T17:02:19.470185+00:00 app[web.1]: module.js:327
2016-07-06T17:02:19.470199+00:00 app[web.1]: throw err;
2016-07-06T17:02:19.470211+00:00 app[web.1]: Error: Cannot find module 'express'
2016-07-06T17:02:19.470212+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:325:15)
2016-07-06T17:02:19.470217+00:00 app[web.1]: at Function.Module._load (module.js:300:12)
2016-07-06T17:02:19.470217+00:00 app[web.1]: at Function.Module.runMain (module.js:441:10)
2016-07-06T17:02:20.579075+00:00 heroku[web.1]: Process exited with status 1
2016-07-06T17:02:20.600663+00:00 heroku[web.1]: State changed from starting to crashed
2016-07-06T17:02:12.174712+00:00 heroku[api]: Deploy 23f2e63 by diegoarcega@gmail.com
答案 0 :(得分:0)
想通了,永远不要忘记在依赖项中安装express而不是devDependencies;)