I'm trying to decrease the size of my openshift backend node app by using webpack to bundle my node file first, and then just push that. Here is the error I'm getting:
Total 642 (delta 200), reused 2 (delta 0)
remote: module.js:471
remote: throw err;
remote: ^
remote:
remote: Error: Cannot find module '/var/lib/openshift/575efb722d5271dec00000f4/app-root/runtime/repo//package.json'
remote: at Function.Module._resolveFilename (module.js:469:15)
remote: at Function.Module._load (module.js:417:25)
remote: at Module.require (module.js:497:17)
remote: at require (internal/module.js:20:19)
remote: at [eval]:1:9
remote: at ContextifyScript.Script.runInThisContext (vm.js:25:33)
remote: at Object.runInThisContext (vm.js:97:38)
remote: at Object.<anonymous> ([eval]-wrapper:6:22)
remote: at Module._compile (module.js:570:32)
remote: at evalScript (bootstrap_node.js:353:27)
remote: CLIENT_MESSAGE: Stopping Node.js application...
Connection to api-tmarr.rhcloud.com closed by remote host.
fatal: The remote end hung up unexpectedly
Here is my webpack config file:
var webpack = require('webpack');
var path = require('path');
var fs = require('fs');
var nodeModules = {};
fs.readdirSync('node_modules')
.filter(function(x) {
return ['.bin'].indexOf(x) === -1;
})
.forEach(function(mod) {
nodeModules[mod] = 'commonjs ' + mod;
});
module.exports = {
entry: './src/app.js',
target: 'node',
output: {
path: path.join(__dirname, 'build'),
filename: 'backend.js'
},
externals: nodeModules,
plugins: [
new webpack.IgnorePlugin(/\.(css|less)$/),
new webpack.BannerPlugin({banner: 'require("source-map-support").install();', raw: true, entryOnly: false})
],
devtool: 'sourcemap'
}
which creates a backend.js file, which is then copied to a skeleton project which just has the bare minimum in it and is hooked up to openshift with git. This new skeleton project has its own package.json & start.js file.
package.json:
{
"name": "API",
"version": "1.0.1",
"description": "Terry's API Server",
"private": true,
"main": "start.js",
"scripts": {
"prestart": "NODE_ENV=production",
"start": "node --use_strict start.js --websocket-port=$OPENSHIFT_NODEJS_PORT --log-level=1"
},
"author": "Terry Marr",
"license": "ISC",
"dependencies": {
"cors": "^2.8.1",
"express": "~3.4.4",
"express-cache-ctrl": "^1.0.1"
},
"engines": {
"node": ">= 0.6.0",
"npm": ">= 1.0.0"
},
"devDependencies": {}
}
Here is the resulting skeletal structure:
/build
-backend.js
-backend.js.map
/node_modules ...
/static ...
/utils ...
-.gitignore
-package.json
-start.js
It might be important that what I'm trying to do is REDO my app. It was working before without webpack. Maybe there's something up there from the old code? Rather new to Openshift, and find the docs not very helpful. Should I clear out my code there and repush? Not sure how to do that. Appreciative of any help.