2017-09-20 1 views
1

J'ai le script postinstall que je suppose être appelé chaque fois que vous faites git push heroku master. Mais pour une raison quelconque, la poussée échoue. Je suis sur Windows et j'ai dû utiliser le package cross-env pour certains des scripts. Je pense que cela peut faire échouer, mais je ne suis pas sûr.Ne pas pousser à maître heroku avec le script npm "postinstall"

Voici une image de la borne de sortie: image

journaux Heroku au fond

Voici les scripts:

"build": "cross-env NODE_ENV=production webpack && gulp", 
"postinstall": "npm run build" 

Voici les webpack et Gulp fichiers:

const webpack = require('webpack'); 
const path = require('path'); 

module.exports = { 
    entry: { 
    app: './src/app.js', 
    }, 
    output: { 
    filename: 'public/build/bundle.js', 
    sourceMapFilename: 'public/build/bundle.map', 
    }, 
    devtool: '#source-map', 
    plugins: 
    process.env.NODE_ENV === 'production' 
     ? [ 
      new webpack.DefinePlugin({ 
      'process.env': { 
       NODE_ENV: JSON.stringify('production'), 
      }, 
      }), 
      new webpack.optimize.UglifyJsPlugin({ 
      minimize: true, 
      compress: { 
       warnings: true, 
      }, 
      }), 
     ] 
     : [], 
    module: { 
    loaders: [ 
     { 
     test: /\.jsx?$/, 
     exclude: /(node_modules)/, 
     loader: 'babel-loader', 
     query: { 
      presets: ['react', 'es2015', 'stage-1'], 
     }, 
     }, 
    ], 
    }, 
}; 

var gulp = require('gulp'); 
var less = require('gulp-less'); 
var gp_concat = require('gulp-concat'); 
var gp_rename = require('gulp-rename'); 
var gp_uglify = require('gulp-uglify'); 
var minifyCSS = require('gulp-minify-css'); 
var autoprefixer = require('gulp-autoprefixer'); 
var path = require('path'); 

gulp.task('css',() => { 
    return gulp 
    .src([ 
     './public/assets/css/font-awesome.main.css', 
     './public/assets/css/ie8.css', 
     './public/assets/css/main.css' 
    ]) 
    .pipe(minifyCSS()) 
    .pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9')) 
    .pipe(gp_concat('style.min.css')) 
    .pipe(gulp.dest('./public/build/css')); 
}); 

gulp.task('build',() => { 
    return gulp 
    .src([ 
     './public/assets/js/jquery.min.js', 
     './public/assets/js/jquery.poptrox.min.js', 
     './public/assets/js/skel.min.js', 
     './public/assets/js/util.js', 
     './public/assets/js/ie/respond.min.js', 
     './public/assets/js/main.js' 
    ]) 
    .pipe(gp_concat('gulp-concat.js')) 
    .pipe(gulp.dest('./public/min')) 
    .pipe(gp_rename('vendor.min.js')) 
    .pipe(gp_uglify()) 
    .pipe(gulp.dest('./public/build/')); 
}); 

gulp.task('default', ['css', 'build'],() => {}); 

2017-09-18T13:55:31.499365+00:00 app[web.1]: npm ERR! A complete log of this run can be found in: 
2017-09-18T13:55:31.499511+00:00 app[web.1]: npm ERR!  /app/.npm/_logs/2017-09-18T13_55_31_493Z-debug.log 
2017-09-18T13:55:31.615780+00:00 heroku[web.1]: Process exited with status 1 
2017-09-18T13:55:33.147165+00:00 app[web.1]: 
2017-09-18T13:55:33.147188+00:00 app[web.1]: > [email protected] start /app 
2017-09-18T13:55:33.147189+00:00 app[web.1]: > node ./bin/www 
2017-09-18T13:55:33.147190+00:00 app[web.1]: 
2017-09-18T13:55:33.760733+00:00 app[web.1]: /app/node_modules/client-sessions/lib/client-sessions.js:548 
2017-09-18T13:55:33.760762+00:00 app[web.1]:  throw new Error("cannot set up sessions without a secret "+ 
2017-09-18T13:55:33.760764+00:00 app[web.1]: ^
2017-09-18T13:55:33.760765+00:00 app[web.1]: 
2017-09-18T13:55:33.760770+00:00 app[web.1]: Error: cannot set up sessions without a secret or encryptionKey/signatureKe 
y pair 
2017-09-18T13:55:33.760770+00:00 app[web.1]:  at clientSessionFactory (/app/node_modules/client-sessions/lib/client-s 
essions.js:548:11) 
2017-09-18T13:55:33.760771+00:00 app[web.1]:  at Object.<anonymous> (/app/app.js:35:3) 
2017-09-18T13:55:33.760771+00:00 app[web.1]:  at Module._compile (module.js:570:32) 
2017-09-18T13:55:33.760772+00:00 app[web.1]:  at Object.Module._extensions..js (module.js:579:10) 
2017-09-18T13:55:33.760772+00:00 app[web.1]:  at Module.load (module.js:487:32) 
2017-09-18T13:55:33.760773+00:00 app[web.1]:  at tryModuleLoad (module.js:446:12) 
2017-09-18T13:55:33.760773+00:00 app[web.1]:  at Function.Module._load (module.js:438:3) 
2017-09-18T13:55:33.760774+00:00 app[web.1]:  at require (internal/module.js:20:19) 
2017-09-18T13:55:33.760773+00:00 app[web.1]:  at Module.require (module.js:497:17) 
2017-09-18T13:55:33.760774+00:00 app[web.1]:  at Object.<anonymous> (/app/bin/www:7:11) 
2017-09-18T13:55:33.760775+00:00 app[web.1]:  at Module._compile (module.js:570:32) 
2017-09-18T13:55:33.760775+00:00 app[web.1]:  at Object.Module._extensions..js (module.js:579:10) 
2017-09-18T13:55:33.760775+00:00 app[web.1]:  at Module.load (module.js:487:32) 
2017-09-18T13:55:33.760776+00:00 app[web.1]:  at Function.Module._load (module.js:438:3) 
2017-09-18T13:55:33.760776+00:00 app[web.1]:  at tryModuleLoad (module.js:446:12) 
2017-09-18T13:55:33.760776+00:00 app[web.1]:  at Module.runMain (module.js:604:10) 
2017-09-18T13:55:33.760777+00:00 app[web.1]:  at run (bootstrap_node.js:389:7) 
2017-09-18T13:55:33.760777+00:00 app[web.1]:  at startup (bootstrap_node.js:149:9) 
2017-09-18T13:55:33.760778+00:00 app[web.1]:  at bootstrap_node.js:502:3 
2017-09-18T13:55:33.774695+00:00 app[web.1]: npm ERR! code ELIFECYCLE 
2017-09-18T13:55:33.775459+00:00 app[web.1]: npm ERR! errno 1 
2017-09-18T13:55:33.776542+00:00 app[web.1]: npm ERR! [email protected] start: `node ./bin/www` 
2017-09-18T13:55:33.776626+00:00 app[web.1]: npm ERR! Exit status 1 
2017-09-18T13:55:33.776766+00:00 app[web.1]: npm ERR! 
2017-09-18T13:55:33.776875+00:00 app[web.1]: npm ERR! Failed at the [email protected] start script. 
2017-09-18T13:55:33.776951+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additiona 
l logging output above. 
2017-09-18T13:55:33.783741+00:00 app[web.1]: 
2017-09-18T13:55:33.783984+00:00 app[web.1]: npm ERR! A complete log of this run can be found in: 
2017-09-18T13:55:33.784118+00:00 app[web.1]: npm ERR!  /app/.npm/_logs/2017-09-18T13_55_33_780Z-debug.log 
2017-09-18T13:55:33.871079+00:00 heroku[web.1]: Process exited with status 1 
2017-09-18T13:55:33.883665+00:00 heroku[web.1]: State changed from starting to crashed 
2017-09-18T13:55:52.250660+00:00 heroku[web.1]: State changed from crashed to starting 
2017-09-18T13:55:52.048172+00:00 app[api]: Set SESSION_SECRET config vars by user [email protected] 
2017-09-18T13:55:52.048172+00:00 app[api]: Release v7 created by user [email protected] 
2017-09-18T13:55:55.840695+00:00 heroku[web.1]: Starting process with command `npm start` 
2017-09-18T13:55:58.323084+00:00 app[web.1]: 
2017-09-18T13:55:58.323119+00:00 app[web.1]: > [email protected] start /app 
2017-09-18T13:55:58.323120+00:00 app[web.1]: > node ./bin/www 
2017-09-18T13:55:58.323121+00:00 app[web.1]: 
2017-09-18T13:55:58.990350+00:00 app[web.1]: (node:18) DeprecationWarning: `open()` is deprecated in mongoose >= 4.11.0, 
use `openUri()` instead, or set the `useMongoClient` option if using `connect()` or `createConnection()`. See http://mo 
ngoosejs.com/docs/connections.html#use-mongo-client 
2017-09-18T13:55:59.019980+00:00 app[web.1]: Db.prototype.authenticate method will no longer be available in the next ma 
jor release 3.x as MongoDB 3.6 will only allow auth against users in the admin db and will no longer allow multiple cred 
entials on a socket. Please authenticate using MongoClient.connect with auth credentials. 
2017-09-18T13:55:59.068033+00:00 app[web.1]: DB CONNECT SUCCESS 
2017-09-18T13:55:59.698175+00:00 heroku[web.1]: State changed from starting to up 
2017-09-18T13:56:08.437795+00:00 heroku[router]: at=info method=GET path="/assets/js/main.js" host=ta-snapshot.herokuapp 
.com request_id=a6710e07-a8f0-4745-9e1c-a235cb2a0252 fwd="24.192.32.162" dyno=web.1 connect=1ms service=6ms status=200 b 
ytes=3324 protocol=https 
2017-09-18T13:56:08.297473+00:00 heroku[router]: at=info method=GET path="/" host=ta-snapshot.herokuapp.com request_id=b 
947354f-896e-464c-aadc-fc02cfc839e1 fwd="24.192.32.162" dyno=web.1 connect=1ms service=39ms status=200 bytes=1680 protoc 
ol=https 
2017-09-18T13:56:08.438162+00:00 heroku[router]: at=info method=GET path="/assets/js/util.js" host=ta-snapshot.herokuapp 
.com request_id=bf8023a7-3cb1-4747-bd3c-a1ffaf1b723c fwd="24.192.32.162" dyno=web.1 connect=0ms service=6ms status=200 b 
ytes=12722 protocol=https 
2017-09-18T13:56:08.437227+00:00 heroku[router]: at=info method=GET path="/assets/js/skel.min.js" host=ta-snapshot.herok 
uapp.com request_id=71672b98-4aa0-4afd-81ea-6fb051a8c62f fwd="24.192.32.162" dyno=web.1 connect=1ms service=6ms status=2 
00 bytes=9373 protocol=https 
2017-09-18T13:56:08.366497+00:00 heroku[router]: at=info method=GET path="/assets/js/jquery.min.js" host=ta-snapshot.her 
okuapp.com request_id=1a37732e-e61e-49ac-b987-51eb0ea99e9e fwd="24.192.32.162" dyno=web.1 connect=1ms service=22ms statu 
s=200 bytes=96247 protocol=https 
2017-09-18T13:56:08.298920+00:00 app[web.1]: GET/200 26.782 ms - 1477 
2017-09-18T13:56:08.361855+00:00 app[web.1]: GET /assets/css/main.css 200 12.223 ms - 50410 
2017-09-18T13:56:08.366349+00:00 app[web.1]: GET /assets/js/jquery.min.js 200 1.785 ms - 95957 
2017-09-18T13:56:08.432865+00:00 app[web.1]: GET /assets/js/jquery.poptrox.min.js 200 1.283 ms - 12113 
2017-09-18T13:56:08.435508+00:00 app[web.1]: GET /assets/js/skel.min.js 200 3.256 ms - 9085 
2017-09-18T13:56:08.437044+00:00 app[web.1]: GET /assets/js/util.js 200 2.149 ms - 12433 
2017-09-18T13:56:08.494412+00:00 app[web.1]: GET /build/bundle.js 200 1.214 ms - 1577443 
2017-09-18T13:56:08.437610+00:00 app[web.1]: GET /assets/js/main.js 200 2.387 ms - 3037 
2017-09-18T13:56:08.364794+00:00 heroku[router]: at=info method=GET path="/assets/css/main.css" host=ta-snapshot.herokua 
pp.com request_id=ff43a00a-5fcf-4a41-b0f3-a971d06bac90 fwd="24.192.32.162" dyno=web.1 connect=1ms service=20ms status=20 
0 bytes=50700 protocol=https 
2017-09-18T13:56:08.434158+00:00 heroku[router]: at=info method=GET path="/assets/js/jquery.poptrox.min.js" host=ta-snap 
shot.herokuapp.com request_id=83fd62f8-f6cc-486b-bf4b-4041a275a249 fwd="24.192.32.162" dyno=web.1 connect=1ms service=3m 
s status=200 bytes=12402 protocol=https 
2017-09-18T13:56:08.518895+00:00 heroku[router]: at=info method=GET path="/build/bundle.js" host=ta-snapshot.herokuapp.c 
om request_id=2dd801e9-e899-4d4a-8a52-dc1fc67b613c fwd="24.192.32.162" dyno=web.1 connect=1ms service=44ms status=200 by 
tes=1577736 protocol=https 
2017-09-18T13:56:09.148354+00:00 app[web.1]: GET /assets/css/font-awesome.min.css 200 4.151 ms - 29063 
2017-09-18T13:56:09.146219+00:00 heroku[router]: at=info method=GET path="/assets/css/font-awesome.min.css" host=ta-snap 
shot.herokuapp.com request_id=39dfd327-c09a-45e4-855a-ebffaa27257c fwd="24.192.32.162" dyno=web.1 connect=1ms service=8m 
s status=200 bytes=29353 protocol=https 
2017-09-18T13:56:09.517771+00:00 app[web.1]: GET /account/currentuser 200 3.193 ms - 38 
2017-09-18T13:56:09.548178+00:00 app[web.1]: GET /api/post?lat=40.7504753&lng=-73.9932668 200 26.721 ms - 39 
2017-09-18T13:56:09.513895+00:00 heroku[router]: at=info method=GET path="/account/currentuser" host=ta-snapshot.herokua 
pp.com request_id=65c8a776-9d5a-47fd-b477-db435f78b797 fwd="24.192.32.162" dyno=web.1 connect=1ms service=7ms status=200 
bytes=245 protocol=https 
2017-09-18T13:56:09.549304+00:00 heroku[router]: at=info method=GET path="/api/post?lat=40.7504753&lng=-73.9932668" host 
=ta-snapshot.herokuapp.com request_id=16272576-6b17-4106-8836-afe0ce8bb34e fwd="24.192.32.162" dyno=web.1 connect=1ms se 
rvice=33ms status=200 bytes=246 protocol=https 
2017-09-18T13:56:10.263855+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=ta-snapshot.herokuapp.com r 
equest_id=2a88ed05-0fad-4990-b29a-30ab227c02fc fwd="24.192.32.162" dyno=web.1 connect=1ms service=15ms status=404 bytes= 
248 protocol=https 
2017-09-18T13:56:10.259213+00:00 app[web.1]: GET /favicon.ico 404 9.124 ms - 41 
2017-09-18T13:56:28.009172+00:00 heroku[router]: at=info method=POST path="/account/register" host=ta-snapshot.herokuapp 
.com request_id=cf25e1dc-d704-4ea4-a4c0-f0688fdf8f83 fwd="24.192.32.162" dyno=web.1 connect=1ms service=241ms status=200 
bytes=569 protocol=https 
2017-09-18T13:56:28.001827+00:00 app[web.1]: { __v: 0, 
2017-09-18T13:56:28.001851+00:00 app[web.1]: _id: 59bfd08b43dd250012c92e1e, 
2017-09-18T13:56:28.001852+00:00 app[web.1]: timestamp: 2017-09-18T13:56:27.968Z, 
2017-09-18T13:56:28.001853+00:00 app[web.1]: password: '$2a$10$70PiciKOFgd04G090zECtOGH2ufENQk7/3vDFkc3x0QgTdNEc8k72', 
2017-09-18T13:56:28.001854+00:00 app[web.1]: username: 'tbaustin' } 
2017-09-18T13:56:28.008043+00:00 app[web.1]: POST /account/register 200 238.870 ms - 128 
2017-09-18T13:56:44.301208+00:00 app[web.1]: GET /api/post?lat=40.75076789772389&lng=-73.99052021796876 200 13.201 ms - 
39 
2017-09-18T13:56:44.302363+00:00 heroku[router]: at=info method=GET path="/api/post?lat=40.75076789772389&lng=-73.990520 
21796876" host=ta-snapshot.herokuapp.com request_id=6b8e57d1-543d-4b0d-9447-28a7861c365a fwd="24.192.32.162" dyno=web.1 
connect=1ms service=18ms status=200 bytes=246 protocol=https 
2017-09-18T13:56:45.284274+00:00 heroku[router]: at=info method=GET path="/api/post?lat=40.75219835694907&lng=-73.993953 
44550783" host=ta-snapshot.herokuapp.com request_id=9472bd9e-c88b-4ca0-888f-ba65dbc3cf83 fwd="24.192.32.162" dyno=web.1 
connect=1ms service=13ms status=200 bytes=246 protocol=https 
2017-09-18T13:56:45.284477+00:00 app[web.1]: GET /api/post?lat=40.75219835694907&lng=-73.99395344550783 200 10.603 ms - 
39 
2017-09-18T13:56:47.609169+00:00 heroku[router]: at=info method=GET path="/api/post?lat=40.75920391164151&lng=-73.990541 
67564088" host=ta-snapshot.herokuapp.com request_id=2ba05865-34bf-433a-a6ba-388fcddfa95a fwd="24.192.32.162" dyno=web.1 
connect=1ms service=10ms status=200 bytes=246 protocol=https 
2017-09-18T13:56:47.607576+00:00 app[web.1]: GET /api/post?lat=40.75920391164151&lng=-73.99054167564088 200 4.460 ms - 3 
9 
2017-09-18T13:57:12.601209+00:00 app[web.1]: POST /api/post 200 31.164 ms - 341 
2017-09-18T13:57:12.604731+00:00 heroku[router]: at=info method=POST path="/api/post" host=ta-snapshot.herokuapp.com req 
uest_id=cb2ae99f-745c-460b-ac31-8c12fe476a40 fwd="24.192.32.162" dyno=web.1 connect=4ms service=37ms status=200 bytes=55 
0 protocol=https 
2017-09-18T14:33:24.565734+00:00 heroku[web.1]: Idling 
2017-09-18T14:33:24.567184+00:00 heroku[web.1]: State changed from up to down 
2017-09-18T14:33:25.533659+00:00 app[web.1]: Error waiting for process to terminate: No child processes 
2017-09-18T14:33:25.472561+00:00 heroku[web.1]: Stopping all processes with SIGTERM 
2017-09-18T14:33:25.653495+00:00 heroku[web.1]: Process exited with status 22 
2017-09-20T15:41:00.000000+00:00 app[api]: Build started by user [email protected] 
2017-09-20T15:41:00.000000+00:00 app[api]: Build failed -- check your build logs 
+0

Quelle est l'erreur Heroku? – skwidbreth

+0

Les journaux heroku ajoutés en bas –

+0

Eh bien, il semble s'agir d'une erreur liée à un module de noeud - '/app/node_modules/client-sessions/lib/client-sessions.js: 548' - toute indication dans le fichier README de ce module à propos du réglage un 'secret ou encryptionKey/signatureKey'? – skwidbreth

Répondre

1

Comme il est prévu par @skwidbreth Je recevais une erreur de session_secret dans les journaux de Heroku. Je suppose que ce n'était pas fourni ou défini d'une manière ou d'une autre. Je l'ai défini dans le fichier .env et dans les configs vars dans heroku, mais cela n'a toujours pas fonctionné.

Ce qui a fait ce travail est en changeant le fichier webpack pour inclure le SESSION_SECRET. Je vais poster le nouveau webpack.config.js

Vous pouvez voir sous à côté de process.env est où je l'ai mis comme recommandé.

const webpack = require('webpack'); 
const path = require('path'); 

module.exports = { 
    entry: { 
    app: './src/app.js', 
    }, 
    output: { 
    filename: 'public/build/bundle.js', 
    sourceMapFilename: 'public/build/bundle.map', 
    }, 
    devtool: '#source-map', 
    plugins: 
    process.env.NODE_ENV === 'production' 
     ? [ 
      new webpack.DefinePlugin({ 
      'process.env': { 
       NODE_ENV: JSON.stringify('production'), 
      }, 
      SESSION_SECRET: JSON.stringify(process.env.SESSION_SECRET), 
      }), 
      new webpack.optimize.UglifyJsPlugin({ 
      minimize: true, 
      compress: { 
       warnings: true, 
      }, 
      }), 
     ] 
     : [], 
    module: { 
    loaders: [ 
     { 
     test: /\.jsx?$/, 
     exclude: /(node_modules)/, 
     loader: 'babel-loader', 
     query: { 
      presets: ['react', 'es2015', 'stage-1'], 
     }, 
     }, 
    ], 
    }, 
};