node.js segmentation fault:11 - node.js

having a problem getting node.js to run. I'm on OSX Lion, followed the installation instructions for node. I'm on v0.5.9-pre, according to node --version, but when I try to run
node app.js
I get "Segmentation fault: 11".
The app.js file is just the hello world example from the main site:
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');
Nothing special. Tried looking over the web, but nothing seems to answer this. Any ideas?

I had this after upgrading from Node 0.4 to 0.6. I just needed to delete the node_modules directory from my app and re-install the dependencies with 'npm install' again.

Never mind. Just used homebrew to install node.js/npm and all working fine now. Thanks anyway.

Related

Why does NodeJS download the file instead of holding the web

I am not sure about why there is a difference between Mac OS & Windows.
The problem is, on Windows environment, the Chrome/Edge downloads the NodeJS response instead of just loading the webpage. Whenever I visit "localhost:8081" on Chrome/Edge, it happens again and again. I would like to do it as what MAC OS does, anyone can save me?!
Windows Side Response
Windows
On MacOS, it does sticking on the browser window.
Any idea for this issue?
Forgot to mention NodeJs version, MACOS: v10.15.3, WINDOWS: v11.12.0
Hopefully, the version doesn't matter in this case. :'(
MacOS
Thanks!
var http = require('http');
http.createServer(function (request, response){
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('HelloWorld');
}).listen(8081);
console.log('server running at http://127.0.0.1:8081/');

node server.js is not working due to syntax error?

I am trying to learn node.js and like many others, the first step is like How to run server written in js with Node.js
However, my problem is syntax problem? (as follows)
server.js
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');
That's a different program called Node. You may want to uninstall it, then install actual Node from here:https://nodejs.org/en/download/

Node.js not working on Windows XP machine

I am just getting started with node.js and I have followed multiple tutorials to get it working on my Windows XP machine.
Downloaded the msi and installed with no issues, opened a command prompt and typed node -v and nothing displays. I created a folder and made a JS file with console.log('hello'); in it, changed to that directory and typed node hello.js and nothing shows.
I then added this code to the hello.js file:
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');
and ran the file from the command line again, it paused briefly and then again displayed nothing.
Been through 10 different tutorials on 10 different sites and can't find a thing to answer this question, even all the information here was no help at this point.
I have also checked the path and it is fine and rebooted the machine just in case.
Seriously stuck!
You need to set your path to node (Environment Variable). Check the following address:
http://www.hacksparrow.com/install-node-js-and-npm-on-windows.html
This is necessary for running node from any folder in the system.
Or you can add node as an enviroment variable in Windows XP's settings:
https://support.microsoft.com/en-us/kb/310519

Cannot run node.js example. module.js:340 throw err cannot find module

When I type in node example.js to my command prompt it gives me an error message.
This is the code I'm using.
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, 'localhost');
console.log('Server running at http://localhost:1337/');
I got that directly from the node.js website and it worked last night. It won't work today. Some help would be appreciated please.
Node.js looks for the file you pass it in the current directory.
If the file only exists in a different directory, it will not be able to find it.
You need to either save the file to the correct directory, or use cd to switch to the directory containing the file.

ares_library_init error in Node.js

I have a problem running a simple Hello World on Node.js. I'm using CentOS and installed it via yum. When I run the file with Node.js, this error pops up:
node: symbol lookup error: node: undefined symbol: ares_library_init
I tried searching google to no avail. I only found that this belongs to the c-ares library. Any idea of how I can solve this?
The file contains this:
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');
Solved it. You can't use yum.
yum remove nodejs
git clone http://github.com/joyent/node.git
cd node
git checkout v0.4.10
./configure
make
make install

Resources