I'm trying to run a node app using pm2. The app by default runs on port 2345, I've changed the config to so it runs in cluster mode and 'instances' is set to max which at the moment only launches 2 instances. As soon as I start the app and both instances of the app launch, one keeps restarting until it does so 15 times at which point it errors out. Looking at the log it complains that"Error: listen EADDRINUSE :::2345"How can I run the app in cluster mode w/o it crashing? Everything I found online points to running the app on a single port and the cluster manages everything. I'd rather have this scale up/down depending on the server resources rather than having to manually edit the config and run X number of apps in fork mode all on different ports.
Submitted July 16, 2018 at 12:34PM by cinek2
Monday, 16 July 2018
JavaScript Engines: The Good Parts
https://www.youtube.com/watch?v=5nmpokoRaZI
Submitted July 16, 2018 at 10:03AM by fagnerbrack
Submitted July 16, 2018 at 10:03AM by fagnerbrack
An npm package that prints todos to the terminal
https://ift.tt/2NQEpIp
Submitted July 16, 2018 at 09:35AM by JakeGore
Submitted July 16, 2018 at 09:35AM by JakeGore
Sunday, 15 July 2018
Issues installing live-server
No matter what I do, I can't seem to get live-server to install properly.I've tried npm -i live-server, yarn global add live-server, and npm install -g live-server.All to no avail.I get this, or some manner of this everytime:"npm WARN optional dep failed, continuing fsevents@1.2.4"Please help!
Submitted July 16, 2018 at 04:37AM by FurFaceMcBeard
Submitted July 16, 2018 at 04:37AM by FurFaceMcBeard
Express error - cannot find module
Hi,I'm trying to get into node.js and Express, and have been following a book (Getting MEAN With Mongo, Express, Angular, and Node). I've got through to halfway through chapter 4, but when I swapped from the single default controller to the two new ones instructed by the book, I've started getting the following error every time I try and run it:PS C:\Users\james\node\loc8r> node . module.js:549 throw err; ^ Error: Cannot find module 'C:\Users\james\node\loc8r' at Function.Module._resolveFilename (module.js:547:15) at Function.Module._load (module.js:474:25) at Function.Module.runMain (module.js:693:10) at startup (bootstrap_node.js:191:16) at bootstrap_node.js:612:3 The files I've modified are:/loc8r/app_server/routes/index.jsvar express = require('express'); var router = express.Router(); var controllerLocations = require('../controllers/locations'); var controllerOthers = require('../controllers/others'); /* Locations category controller */ router.get('/', controllerLocations.homelist); router.get('/locations', controllerLocations.locationInfo); router.get('/locations/review/new', controllerLocations.addNew); /* Others category controller */ router.get('/about', controllerOthers.about); module.exports = router; /loc8r/app_server/controllers/locations.js/* GET homepage */ module.exports.homelist = function(req, res) { res.render('index', {title: 'Home'}); }; /* GET Location info */ module.exports.locationInfo = function(req, res) { res.render('index', {title: 'Location info'}); }; /* GET add review page */ module.exports.addNew = function(req, res) { res.render('index', {title: 'Add a review'}); }; /loc8r/app_server/controllers/others.js/* GET about page */ module.exports.about = function(req, res) { res.render('index', {'title': 'About Loc8r'}); }; I'm aware that this folder structure isn't how things are done by default but it's the way the book recommends it be done for neatness. It worked fine with the default route and with the default route split into a route and a controller, but not since. I'm sure it's an obvious mistake but I've searched and can't find any answer. VS Code doesn't highlight any formatting errors so I've given up hope it's something glaring for me to fix like that.Node is v8.11.3, NPM is v5.6.0, Express is v 4.6.13 according to npm listCould someone also advise how I'd go about following back through the error message to work out where I've gone wrong?Many thanks,James
Submitted July 16, 2018 at 12:13AM by jamesm_14
Submitted July 16, 2018 at 12:13AM by jamesm_14
What is the standard way to store runtime settings?
I currently develop an app that consists of 3 separate packages for now and they all share the same database (it's MySQL).Now I want to give user an ability to toggle some features on/off using some interface (I believe it doesn't matter, it could be web page with form, REST endpoint, etc) so my app should be able to save this setting somewhere and retrieve it when needed.What is the best way to do this?The most obvious way for me was using of JSON file but I don't think that it's a right way because my app may have hundreds of settings and I think that I should use database for this because it's application data after all.I came with idea to use settings table where I have text key and JSON value. JSON because MySQL supports it natively and settings may have different type of values. Then I can have some wrapper class that will fetch all settings from database and reload them when something changes (so I don't have to do DB requests when I need to check some setting).Is it OK?
Submitted July 15, 2018 at 11:03PM by Max_Stern
Submitted July 15, 2018 at 11:03PM by Max_Stern
Am I webpacking my modules incorrectly?
I've been trying to publish modules, and I've even followed some tutorials on how to do it. They publish fine and run fine as ES6 in dev mode, and even when I publish them Webpack'd as ES5, they work fine in dev mode. But when I do a production build of a create-react-app, I get an error:Failed to compile. Failed to minify the code from this file: ./node_modules/MY_MODULE/index.min.js:1:1198 Read more here: http://bit.ly/2tRViJ9 error Command failed with exit code 1. This happens for all of my modules, no matter how simple or complicated they are.Here's my webpack file for the module in question:const path = require('path'); module.exports = { entry: './index.js', mode: 'production', module: { rules: [ { test: /\.js$/, use: { loader: 'babel-loader' } } ] }, output: { filename: 'index.min.js', library: 'MY_MODULE', libraryTarget: 'umd', path: path.resolve(__dirname, '.'), umdNamedDefine: true } }; Here's my minified output, in case anything is glaringly obvious to anyone:!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("react-object-prop",[],t):"object"==typeof exports?exports["react-object-prop"]=t():e["react-object-prop"]=t()}(window,function(){return function(e){var t={};function r(o){if(t[o])return t[o].exports;var n=t[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,o){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(o,n,function(t){return e[t]}.bind(null,n));return o},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t){const r=()=>{let e=Object.create(null);return t=>{let r=!1;const o=Object.create(null);for(const[n,u]of Object.entries(t))Object.prototype.hasOwnProperty.call(e,n)&&e[n]===u||(r=!0),o[n]=u;return r&&(e=o),e}};r.default=r,e.exports=r}])}); I've run out of ideas. All help is greatly appreciated.If direct links help, a simple module is react-object-prop and a complex module is react-portfolio. Both give "failed to minify" errors for create-react-app build. Am I just building it incorrectly with libraryTarget: 'umd'? I
Submitted July 15, 2018 at 07:32PM by GAMEchief
Submitted July 15, 2018 at 07:32PM by GAMEchief
Subscribe to:
Posts (Atom)