Basic Node.js setup on Windows - node.js

I'm trying to get node.js to run a sample script I've created. I'm using Windows. mysamplescript.js is in the same folder as the node.js executable. When I type in
node mysamplescript.js
I get ... returned on the next line. The docs for node aren't exactly stellar. Am I missing something?

Related

Please specify node.js interpreter correctly WebStorm error

I'm trying to simply create a React Native project via Webstorm but I get this error upon trying to do so which's resulting in myself not being able to start a project.
Whenever I do choose a Node interpreter it gives me an error that says Unspecified react-native cli package at the same spot that says Please specify node.js interpreter correctly.
I've been starting React Native projects like this since the beginning but this time I get this error out of no where, I don't know where it came from. How can I fix this?
Opens up your terminal, and use the which command to find our your NodeJS interpreter
$ which node
/Users/felixfong/.nvm/versions/node/v8.0.0/bin/node
And copy that result, and update your Node interpreter field inside yoru WebStorm
Hopes this help

Trying to get MEAN maps to work on windows

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...

Installed Node.js and Sublime Text But Keep Getting Errors

I'm a beginner at trying to learn web development. I currently downloaded node from the nodejs.org website and also downloaded Sublime Text 3 from the website as well.
My code for sublime is as follows:
$ node
console.log("Who's you're daddy?");
When I try to run it on node.js I get an error that says:
"Syntax Error, Unexpected Identifier."
This is literally step one and I'm already messing up. How have I set this up wrong?
From What you are trying to do seems like you want to print "Some String" in the console using nodejs.
In nodejs you can create a javascript logic first and then you can execute that logic using node.
Create a file somefile.js
Write following code in the file:
console.log('Who's your daddy?');
In terminal and execute:
node /location/of/the/file/somefile.js
It should print 'Who's your daddy?' in the console.
To learn more about nodejs and to get started you can refer to How do I get started with Node.js

Issue with Node-based Cordova Hook

I'm playing around with the Cordova hooks capabilities and I'm trying to test using a node application as a hook. In this article: http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/ it references running node applications, so I know it's possible.
I've created a simple node application that I'm using to test the before prepare and after prepare process:
#! /usr/bin/env node
console.log("this is a node module");
When I run my prepare, I get the following error:
C:\Users\jwargo\dev\lunchmenu>cordova prepare
The system cannot find the path specified.
Hook failed with error code 1: C:\Users\jwargo\dev\lunchmenu\hooks\before_prepare\test.js
I can't find any information anywhere about what an error code of 1 means here.
I've tested the node code and it runs fine with "node test.js" and when I execute test.js from the command line Windows simply launches my default editor.
So, can anyone tell me what I'm doing wrong or what I need to do to be able to execute a node application as a hook with the Cordova CLI?
Figured it out with some help from the Cordova dev team. The space in my shebang was causing the problem. I removed it and the problem went away.

getting node.js working

So I'm following:
http://giantflyingsaucer.com/blog/?p=894
and installing node.js.
I got up to the part with sudo make install.
It works, then it says to create a js file.
What I don't understand is where I put the sayhello.js?
Node.js looks at least for the programmer more like a interpreter. Thus, you can place your sayhello.js whereever you want and run it by executing node sayhello.js.
However, you might consider using external modules. Then you must check that they are set by full path or the relative path can be resolved from the location you execute node in.

Resources