Well I am working on pull request on Heroku project I am experiencing following issue with it:
-----> Deleting 1 files matching .slugignore patterns. -----> Node.js app detected -----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error NPM_CONFIG_PRODUCTION=false NODE_VERBOSE=false NODE_ENV=production NODE_MODULES_CACHE=true
-----> Installing binaries engines.node (package.json): 9.3.0 engines.npm (package.json): 5.5.1
Resolving node version 9.3.0... Downloading and installing node 9.3.0... npm 5.5.1 already installed with node
-----> Restoring cache Loading 2 from cacheDirectories (default): - node_modules - bower_components (not cached - skipping) -----> Building dependencies Installing node modules (package.json) uglifyjs-webpack-plugin@0.4.6 postinstall /tmp/build_0205c32fc162b04a5bd36ce6d3e2a31a/GithubUsername-projName-45f1019/node_modules/webpack/node_modules/uglifyjs-webpack-plugin node lib/post_install.js projName@0.3.0 postinstall /tmp/build_0205c32fc162b04a5bd36ce6d3e2a31a/GithubUserName-projName-45f1019 webpack -p --config ./webpack.config.js --progress
90% chunk assets pro Version: webpack 3.10.0 Time: 25301ms Asset Size Chunks Chunk Names ///All chunk files emitted details projname.js 1.27 MB 0 [emitted] [big] main favicon.ico 17 kB [emitted] index.html 37.4 kB [emitted] [14] ./src/script.js 3.92 kB {0} [built] //built details + 208 hidden modules ERROR in ./src/assetLoader.js Module not found: Error: Can't resolve './manifest' in '/tmp/build_0205c32fc162b04a5bd36ce6d3e2a31a/GithubUsername-projName-45f1019/src' @ ./src/assetLoader.js 1:0-34 @ ./src/game.js @ ./src/script.js ERROR in proj.js from UglifyJs Unexpected token: name (Creature) [GithubUsername-projName.js:1,99245] Child html-webpack-plugin for "index.html": Asset Size Chunks Chunk Names [2] ./node_modules/html-webpack-plugin/lib/loader.js!./src/index.html
[built] [4] (webpack)/buildin/global.js 509 bytes {0} [built] [5] (webpack)/buildin/module.js 517 bytes {0} [built] [6] ./assets/interface/AB.gif 82 bytes {0} [built] [7] ./assets/interface/ProjPage.png 82 bytes {0} [built] npm ERR! code ELIFECYCLE npm ERR! errno 2 npm ERR! projName@0.3.0 postinstall:
webpack -p --config ./webpack.config.js --progress
npm ERR! Exit status 2 npm ERR! npm ERR! Failed at the projName@0.3.0 postinstall script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.npm ERR! A complete log of this run can be found in: npm ERR! /app/.npm/_logs/2018-01-03T13_35_09_304Z-debug.log
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here: https://devcenter.heroku.com/articles/troubleshooting-node-deploys If you're stuck, please submit a ticket so we can help: https://help.heroku.com/ Love, Heroku ! Push rejected, failed to compile Node.js app. ! Push failed
here is code for:
snippet of package.json
{
"dependencies": {
"compression": "^1.6.2",
"express": "^4.13.4",
"html-webpack-plugin": "^2.30.1",
"jquery": "1.12.4",
"jquery-mousewheel": "3.1.13",
"jquery-ui": "^1.12.1",
"jquery.kinetic": "2.2.4",
"jquery.transit": "0.9.12",
"phaser-ce": "2.7.10",
"socket.io": "^1.3.5",
"socket.io-client": "1.3.5"
},
"devDependencies": {
"css-loader": "^0.28.7",
"eslint": "^4.12.1",
"expose-loader": "^0.7.4",
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^1.1.5",
"less": "^2.7.3",
"less-loader": "^4.0.5",
"prettier": "^1.8.2",
"style-loader": "^0.19.0",
"uglifyjs-webpack-plugin": "^1.1.2",
"webpack": "^3.8.1",
"webpack-merge": "^4.1.1"
},
"scripts": {
"start": "node server.js",
"postinstall": "webpack -p --config ./webpack.config.js --progress",
"build": "yarn run generateManifest && webpack --env.production",
"build:dev": "yarn run generateManifest && webpack",
"dev": "webpack --watch",
"lint": "eslint src/**/*.js",
"generateManifest": "node manifestGenerator.js"
}
}
Server.js
// Setup basic express server
var compression = require('compression');
var express = require('express');
var app = express();
var server = require('http').createServer(app);
var io = require('socket.io')(server);
var port = process.env.PORT || 8080;
var ip = process.env.IP || '127.0.0.1';
var gameManager = require('./server/gamemanager.js');
var qManager = require('./server/queuemanager.js');
// Setup the game queue and connection details
io.on('connection', function(session) {
console.log('a user connected');
// Store the username in the socket session for this client
var username = makeid();
session.username = username;
// Add user to the queue
qManager.addToQueue(session);
session.on('disconnect', function() {
console.log('user disconnected');
qManager.removeFromQueue(session);
});
// Send user the username
session.emit('login', session.username);
});
// Listen for server, and use static routing for deploy directory
server.listen(port, function() {
console.log('Server listening at port %d', port);
});
app.use(express.static('./deploy', {
maxAge: 86400000
}));
webpack.config.js code
const path = require('path');
const webpack = require('webpack');
const merge = require('webpack-merge');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
// Are we in production
const production = process.env.production;
const baseSettings = {
entry: path.resolve(__dirname, 'src', 'script.js'),
output: {
path: path.resolve(__dirname, 'deploy/'),
filename: 'projname.js'
},
module: {
rules: [
{
test: /\.less$/,
use: [
'style-loader',
'css-loader',
'less-loader',
]
},
{
test: /\.css$/,
use: [
'style-loader',
'css-loader',
]
},
{
test: /\.(png|jpg|gif|svg|ogg|ico|cur|woff|woff2)$/,
use: [
'file-loader'
]
}
]
},
resolve: {
alias: {
assets: path.resolve(__dirname, 'assets/'),
modules: path.join(__dirname, "node_modules")
}
},
plugins: [
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'src', 'index.html'),
favicon: path.resolve(__dirname, 'assets', 'favicon.ico')
}),
]
}
const prodSettings = {
plugins: [
new UglifyJSPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
})
]
}
const devSettings = {
devtool: 'cheap-module-eval-source-map'
}
// Create either a production or development build depending on the `production` env setting
module.exports = merge(baseSettings, production ? devSettings : prodSettings);
I am not able to understand what the issue with web pack is their something wrong with my postinstall script? Am i missing any rules while tweaking script?
I tried applying some solutions from SO and Heroku documentation but nothing working ...Please Help !!! Thank you in advance!!! Feel free to comment for any other info.!!!