Installed Node.js and Sublime Text But Keep Getting Errors - node.js

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

Related

I've got nodejs installed but trying to run code in the terminal shows error "can't find module"

VScode error message saying shell integration not activated
Judging from your Screenshot:
The javascript file is located at ~/Documents/MY PROJECTS/hello.js.
You are trying to run a hello.js file in ~.
~ would be EDWIN in your case.
Since Node js can't find the hello.js file it throws an error. Locate the correct directory with cd Documents/MY PROJECTS and then try to run the js file via node hello.js

Setup node.js on Windows to use with p5.js "Uncaught ReferenceError: cd is not defined"

I'm very very very new to this and I'm trying to follow along this Introduction to Node tutorial on how to set up Node.js to work with p5.js
The tutorial is for Mac but so far I've managed to do this:
Setup node for windows:
Download Node
Install Node
Open cmd
Type node + enter
Type cd to change directory
And here I get this message:
"Uncaught ReferenceError: cd is not defined"
I've tried to work around by open in PowerShell but get stuck there as well. What should I do?
:))
In case anyone else look for this, here's the solution that worked for me.
In PowerShell:
Ctrl+C once or twice. And instead of running node first, type node + whatever you need to run

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

Basic Node.js setup on Windows

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?

Resources