Trying to get MEAN maps to work on windows - node.js

I cloned this mean map that I watched on a azure mongodb video , and I did the same steps in the readme like they did
https://github.com/scotch-io/mean-google-maps
So
npm install
node server.js
// I didn't do any mongodb , as there is a config.js that is pointing at an amazon mongodb.
On the video they didn't do any mongodb locally
I see that in chrome console it throws an error with modernizr
#!/usr/bin/env node
That line is red squiggly , it that line causing the map to not load? Is that even going to work on a Windows 10 machine I'm running?

This error has nothing to do with mongodb.
The problem is the Modernizr link in the public/index.html (line 18) points to a script which is designed to be run server side.
The shebang #!/usr/bin/env node indicate a javascript file that must be run with Nodejs. Your browser can't run this kind of script.
It's looks like a confusion in bower dependency management.
(I think it is generaly not a good practive to include bower_components directory into git repository)
Maybe you can try to fix it by replacing the link with a cdnjs version of Modernizer:
https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.js
Or just delete the line, you use a recent Chrome browser after all...

Related

PM2 starting Meteor App not working

I have in one Digital Ocean Linux Ubuntu 16.041 droplet an instance of a Meteor app. Moreover, I installed Node.js version of 4.4.0
I created the respective bundle on the path ~/MyApplication/bundle. As a matter of fact, I automated with a config.json file the execution which its body contains the following code:
My main.js file is created from the Meteor build --directory ~/myDirectory/ command and contains the following code:
process.argv.splice(2, 0, 'program.json');
process.chdir(require('path').join(__dirname, 'programs', 'server'));
require('./programs/server/boot.js');
That being said, I run my application with pm2 through the config JSON file with pm2 start config.json
It starts the application, but several ms afterwards it is errored. The log error show the following exception regarding the typo, but seems the mainjs file is created fine. Any suggestions to solve it?
In the end, I had to update the node version in the server from 4.4.0 to 8.9.1. After doing that changes, I also had to install the dependencies within the bundle/programs/server/ using npm install

Adding a custom Node JS version to openshift doesn't work for my app

I have written an application which needs Node.js >= 4.2.6
I'm using the OpenShift service and the default Node.Js version is 0.10. Installing this https://github.com/ryanj/nodejs-custom-version-openshift is supposed to resolve this problem. So I followed the instructions and created a new application using:
rhc app create nodeapp nodejs --from-code=git://github.com/ryanj/nodejs-custom-version-openshift.git
So far so good. Next step - copy my project to the cloned git repository. Here's where I'm unsure if my approach is right (new to Node js). Because the cloned git already has a JSON package and because my app has its own JSON package in its root directory, I enriched the JSON package that came with nodejs-custom-version-openshift.git with my dependencies and set the engines to 4.2.6. The main is set to server.js. To run my app, I'm using "var variable = require('./myapp-master/test/test');" as the last line in my server.js. I copy the content of my app to the cloned repository (including node modules etc.) careful not to overwrite any existing config files like the JSON Package and then I use git push. The node version is installed properly according to the logs (upon build), servers.js is executed and it invokes my test.js. I can see in the app logs (app-root/logs) that test.js throws a specific error that indicates that the node js version is not >= 4.2.6.
When I log-in with PUTTY and write node -v, I get 4.2.6. When I navigate to my test.js and start it manually with node test.js, it runs normally. What am I doing wrong? I suspect I'm not handling the JSON packages properly (or my approach with starting my app from server.js is flawed). Any help is greatly appreciated! Thank you for your time.
Ok, I found the solution to this: https://github.com/ryanj/nodejs-custom-version-openshift/issues/2

broccoli-closure-compiler install error

I am trying to test es-6 promise-polyfill, for the testing one the node packages requried is broccoli-closure-compiler, which is not getting installed, I am behind a proxy server, is that the problem, but i have proxy config for both git and npm, so they are working fine, for more info, please refer to the screenshot of the command prompt,
edit:
the text in screenshot
D:\pt>npm install broccoli-closure-compiler
npm WARN package.json jshint#0.9.1 No repository field.
\
closurecompiler#1.3.2 install D:\pt\node_modules\broccoli-closure-compiler\node_modules\closurecompiler
npm run-script configure
\
closurecompiler#1.3.2 configure D:\pt\node_modules\broccoli-closure-compiler\node_modules\closurecompiler
node scripts/configure.js
Configuring ClosureCompiler.js 1.3.2 ...
Downloading http://dl.google.com/closure-compiler/compiler-latest.tar.gz ...
? Download failed: Error: connect ETIMEDOUT
? Unfortunately, ClosureCompiler.js could not be configured.
See: https://github.com/dcodeIO/ClosureCompiler.js (create an issue maybe)
what I am suggesting is not a solution, these are mere work-around( aka really bad hacks)
if you are facing this, it is because you are behind a proxy server and one of the scripts trying to install clousurecompiler does not have the proxy settings set.
work around one : well, find a way to connect without proxy server, or install in a machine outside proxy server, copy the node_module files to your system,
work around 2 (the one I used) :
when you look at the screenshot, you would notice that at one point "node scripts/configure.js" is run, this is the crucial point, find a way to pause the processing just before this point,
open the 'configure.js' file, it would be at '.\node_modules\broccoli-closure-compiler\node_modules\closurecompiler\scripts' in node project directory,
comment line 65 in that i.e fail(); to //fail();
continue the installation process,
manually download http://dl.google.com/closure-compiler/compiler-latest.tar.gz , put the extracted file at '.\node_modules\broccoli-closure-compiler\node_modules\closurecompiler\compiler' in your project directory
(... told you this is a bad solution )

Installing a Web Server for Node.js

I'm trying to follow a book I purchased called "Pro Angular JS", and I am having trouble getting a web server pointed to the right port. So I go to the command line, run Node, and the first error I get is this, when trying to install connect:
npm should be run outside of the node repl, in your normal shell.
(Press Control-D to exit.)
Ok, fair enough. So I do as the command specifies, and I get it to install just as the user, and it ends up adding a folder called node_modules in my user root folder. Ok, seems like everything still makes sense.
Now, the book tells me to create a server.js file within the Node.js installation folder. There is no Node.js installation folder actually created on my user. I see the node_modules folder for sure. So I'm guessing the root directory of my user is where node.js was installed but maybe it's hidden or something? I believe when I used the Mac installer for Node, it said it was created at usr/local/bin. But I have no idea if that is my user on my computer, or even more root access to my computer.
Lastly, back to this server.js file...so I created it with a text editor, containing this code:
var connect = require('connect');
connect.createServer(
connect.static(".../angularjs")
).listen(5000);
And of course they want me to add this file to the directory where my Node is installed. Currently, it's sitting where my current user (user is kst001) root directory is. This is also where my node_module folder was created when I installed it using the npm install connect line in the shell. They also wanted me to create a folder called angularjs, where I would store my app, and said to place it in the root directory where node.js was installed. Once again, sitting in the root directory with everything else. Yet, when I try and fire up my test document in port 5000 (localhost:5000/test.html), I get a "could not find page" error.
Already tried using this link to solve my problem, which seems dead on for my issue, but it resolved nothing:
Node / connect issue Object function createServer has no method static
I'm using a Mac, by the way. Any ideas, guys? Any help would be much appreciated.
The reason why connect.static() does not work is that the latest major version of connect (3.x) no longer contains all of the middleware that connect was bundled with in 2.x.
The readme for connect has a list of middleware references that show you the name of the module on npm that gives you the old functionality for each middleware (e.g. static is now broken out into its own module serve-static).
I'm following the same book/example and the following works. I claim no credit, it is from another Stack Overflow answer about setting up a simple server plus the contents of a comment on the same answer (question 24346161 link to it from here: nodejs connect cannot find static)
Because I used it in exactly the same learning context (book I also purchased called "Pro Angular JS") and I have been around the houses for 3 hours trying to sort this out (yes a complete novice), I thought I would post it here.
firstly from your node installation directory
npm install serve-static
secondly, your node server.js code for a simple static server to serve your angularjs directory contents in a localhost:5000 browser window, on a Windows 7 machine should be (as at July 2015) ...
var connect = require('connect'),
serveStatic = require('serve-static');
var app = connect();
app.use(serveStatic("./angularjs"));
app.listen(5000);
I just stuck a simple index.html file in the angularjs directory to begin with containing
connection working
to test it and it worked a treat.

heroku running gulp build

i am trying to install a node app onto heroku. My application requires both gulp build and gulp install to be called on the server upon instillation, however i am having troubles doing this.
I have tried writing this inside of the package.json:
"scripts":"gulp build && gulp install"
which works at first, but after about an hour the server must restart and recall the script causing for the contents of the server to be rebuilt. this removes all of my content such as newly written blogs or changes.
I have also tried using the heroku toolbelt
heroku run gulp build
heroku run gulp install
However, even though it produces the correct console write lines and looks asif it has made the necessary changes, it hasn't, the server produces an error which proves that the resources haven't been built meaning that the console command didnt make any changes to the actual server files.
Am i missing something out here? Thanks in advance.
So i have figured out that the problem lies with the fact that i have tried to use a LevelDB database on heroku. Apparently, heroku uses no-writable dynos, meaning that the levelDB database is unable to save.

Resources