-
Notifications
You must be signed in to change notification settings - Fork 2k
feat(server): Add warning if using an unsupported version of Node #1657
Conversation
I've also taken the liberty to add an extra condition that disables the warning about an empty config.domain, unless in production environment mode. It is offputting for a new user to be presented with an "important warning" like that when they are running the app for the first few times on their local machine. |
@@ -47,6 +47,7 @@ module.exports.start = function start(callback) { | |||
console.log(chalk.green('App version: ' + config.meanjs.version)); | |||
if (config.meanjs['meanjs-version']) | |||
console.log(chalk.green('MEAN.JS version: ' + config.meanjs['meanjs-version'])); | |||
console.log(chalk.green('Node version: ' + process.version.substr(1))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hyperreality please ping me when/if this PR goes in and I'll remove similar line from my PR. Cheers!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do prefer the location of this line in Mikael's PR. Seems more apropos for it to be grouped with the app, server, and db settings display.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, are there really a lot of these cases where |
BTW a fine implementation of the check otherwise! |
*/ | ||
var validateDomainIsSet = function (config) { | ||
if (!config.domain) { | ||
if (!config.domain && process.env.NODE_ENV === 'production') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A separate PR for this would be more suitable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 on this change in a separate PR. However, I'm not sold on the idea. I understand that it may be alarming to first time users of this framework. However, the byproduct of this change could be more impacting & scary for a user that sees this warning for the first time when they deploy their app to a production environment.
Does it make more sense to leave this warning for all environment's to at least make the user aware of this potential config flaw? As they use the app in their development environment, a user will realize that it doesn't really stop their app from working but it's something they must think about as they approach deployment to production.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My rationale behind the change was the following:
- Seeing many people install new software, getting a red error message about configuration post-install is unexpected - the first thought is that something went wrong during the installation process, probably with Node.
- By the time users actually deploy, I would expect them to have run the app several times in production mode in a safe environment to check it: providing multiple opportunities to see the message.
Anyway, I can see where you're coming from @mleanos. I think what we really need is just a better and more descriptive message. What do you mean by scary implications?. I believe you might be best placed to write the message ;-). I'll remove the change for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you're saying @hyperreality. However, maybe we could just "introduce" them to the idea of the domain setting needing to be set; can we show this message as a warning in non-Production environments, and display as a critical (red) error when in production?
I don't want to over-complicate that matter, but I do think we can address the underlying issue of user's getting confused. My statement of "scary" was more that after some time spent on development, with everything working as expected, and to all of a sudden see a message like that in a production environment (whether local or deployed) could give someone a moment of panic. Either way, we can pick this up in a separate PR.
I'm wondering this as well. I am feeling the pain a little bit with all the support issues coming in that are related to the Node version; not to mention the issues revolving around the generator :( I do like the implementation of the check though. So I'm not opposed to this going in, even if it is redundant. I'm more concerned with what the real issues are with running Node 7. Are they easily fixed, or are they more-or-less issues with the packages we're using? |
It's not just the |
It turns out that we could probably eliminate this whole class of issues more efficiently, with a |
@mleanos I just tried MEAN with Node 7.2.0 and the only problems I had were with Node-sass, commenting that out of the gulpfile and everything ran smoothly - and with the server-side Mocha tests. Obviously that's after installing everything with a lower version of Node, #1652 had problems with |
@hyperreality I like the idea of the |
I just wrote the preinstall script which worked nicely on Node < 4.6.0 but strangely it didn't seem to run on Node 7. Turns out NPM 3 has a problem, actually running preinstall post-install: npm/npm#10379, which has been around for a year now. So maybe this truly is impossible to achieve. |
How about this? scripts: {
"check-prerequisites": "node scripts/checkPrerequisites.js",
"install": "npm run check-prerequisites && npm install"
} Edit: nope, that's obviously a loop. :-) A bit sleep here. |
It turns out that in Npm 3.10.8 onwards the preinstall script does run before node_modules is installed, but only after http requests have been made. So it could still be useful. However, because modules have not been installed at that stage the checkPrequisites file would have to bundle a fair amount of the Semver library code, what do you think about this @simison @mleanos? |
do be honest I don't think I like this in. |
+1 @lirantal
would make sense for CMS but mean.js is a bolerplate...
|
Agreed. |
As suggested by @codydaig at #1655. A lot of the issues here recently have been raised by people simply running the wrong versions of Node, and while the majority are errors during the
npm install
step, sometimes the user will inadvertently manage to run MEAN with the wrong Node version and encounter weird errors... hopefully this will prevent that.