Iam a newbie to node.js and when I tried to run the Hello world application it showed error.I created a main.js file and using node repl i called the $ node main.js.It resulted in error
SyntaxError: Unexpected identifier
at Object.exports.createScript (vm.js:24:10)
at REPLServer.defaultEval (repl.js:221:25)
at bound (domain.js:280:14)
at REPLServer.runBound [as eval] (domain.js:293:12)
at REPLServer.<anonymous> (repl.js:412:12)
at emitOne (events.js:82:20)
at REPLServer.emit (events.js:169:7)
at REPLServer.Interface._onLine (readline.js:210:10)
at REPLServer.Interface._line (readline.js:549:8)
at REPLServer.Interface._ttyWrite (readline.js:826:14)
After that I tried the same with normal command prompt.I traversed to main.js and executed node main.js then it showed the output.But in examples, the JS is executed using the node repl.Its totally confusing.If I try $ node in repl it also shows error. Please help
You need to execute node main.js at your OS command/shell prompt, not the node repl.
Related
I'm trying to do a little debugging with node.js, but the stack trace is leading me into a weird file called events.js. (no path is provided)
What is that file? Where can I find it?
Trace: Test
at Socket.socket.on (C:\test\SocketTest\server.js:11:13)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at Socket.onevent (C:\test\SocketTest\node_modules\socket.io\lib\socket.js:335:8)
at Socket.onpacket (C:\test\SocketTest\node_modules\socket.io\lib\socket.js:295:12)
at Client.ondecoded (C:\test\SocketTest\node_modules\socket.io\lib\client.js:193:14)
at Decoder.Emitter.emit (C:\test\SocketTest\node_modules\component-emitter\index.js:134:20)
at Decoder.add (C:\test\SocketTest\node_modules\socket.io-parser\index.js:247:12)
at Client.ondata (C:\test\SocketTest\node_modules\socket.io\lib\client.js:175:18)
at emitOne (events.js:96:13)
Quote from the nodejs documentation:
Node.js has several modules compiled into the binary. These modules are described in greater detail elsewhere in this documentation.
The core modules are defined within Node.js's source and are located in the lib/ folder.
Emphasis mine. So if you don't build nodejs from source code, you won't have it on your file system (hence the missing path).
Anyway, you will encounter it in most traces, but its extremely unlikely that it has anything to do with your actual problem.
I'm getting this error when openssl child proccess is trying to write() to local directory.
Connection is closed before write() is called. It isn't connected with the ssl, because I can't even launch example code from nodejs documentation.
What am I missing? Some kind of special rights for nodejs?
Please, can anyone give me a real example how to use childProccess.stdin.write()?
events.js:85
throw er; // Unhandled 'error' event
^
Error: write EPIPE
at exports._errnoException (util.js:746:11)
at Socket._writeGeneric (net.js:690:26)
at Socket._write (net.js:709:8)
at doWrite (_stream_writable.js:301:12)
at writeOrBuffer (_stream_writable.js:288:5)
at Socket.Writable.write (_stream_writable.js:217:11)
at Socket.write (net.js:634:40)
at signManifest (...\node_modules\passbook\lib\pass.js:360:14)
It appeared that i've installed openssl in a wrong way. An error (wrong openssl directory) while execFile(openssl) emitted 'close' event, so write threw EPIPE.
Be careful and add a lot of proper error handlers :)
I'm trying to make a server using Node.js and Box2dWeb engine. But trying to "import" the "box2d.js" throws me a random error which doesn't seem to be related with what I'm doing. Here's the code that's causing the error:
var Box2D = require('./box2d.js');
Here's the error:
console.js:55
this._stdout.write(util.format.apply(this, arguments) + '\n');
^
TypeError: Cannot read property 'write' of undefined
at Console.log (console.js:55:15)
at TCPServer.<anonymous> (C:\Users\conne_000\Documents\ntm2\NTM2Server2\main
.js:16:10)
at TCPServer.emit (events.js:129:20)
at Server.<anonymous> (C:\Users\conne_000\Documents\ntm2\NTM2Server2\classes\servers\tcp_server.js:20:8)
at Server.emit (events.js:104:17)
at net.js:1171:12
at process._tickCallback (node.js:355:11)
at Function.Module.runMain (module.js:503:11)
at startup (node.js:129:16)
at node.js:814:3
Press any key to continue . . .
I have no idea on what to do about this. Any help is very much appreciated!
We run a node app on heroku. The app makes outgoing https connections to many services, but we can't reproduce our problem with any of these services. We are occasionally (6 times in the last 30 minutes) seeing this error appear and having a hard time tracking it down:
Error: CERT_UNTRUSTED
at SecurePair.<anonymous> (tls.js:1381:32)
at SecurePair.emit (events.js:92:17)
at SecurePair.maybeInitFinished (tls.js:980:10)
at CleartextStream.read [as _read] (tls.js:472:13)
at CleartextStream.Readable.read (_stream_readable.js:341:10)
at EncryptedStream.write [as _write] (tls.js:369:25)
at doWrite (_stream_writable.js:226:10)
at writeOrBuffer (_stream_writable.js:216:5)
at EncryptedStream.Writable.write (_stream_writable.js:183:11)
at write (_stream_readable.js:602:24)
at flow (_stream_readable.js:611:7)
at Socket.pipeOnReadable (_stream_readable.js:643:5)
at Socket.emit (events.js:92:17)
at emitReadable_ (_stream_readable.js:427:10)
at emitReadable (_stream_readable.js:423:5)
at readableAddChunk (_stream_readable.js:166:9)
at Socket.Readable.push (_stream_readable.js:128:10)
at TCP.onread (net.js:529:21)
at TCP.onread (/app/node_modules/newrelic/node_modules/continuation-local-storage/node_modules/async-listener/glue.js:177:31)
The only hint about files is the newrelic module at the bottom, which I assume would be in any stacktrace. Does anyone have advice for figuring out where this error is coming from?
If you are using node 0.10.34, this could be the issue
https://github.com/joyent/node/issues/8894
Recommend using v0.10.33 for now.
I am developing a prototype web application. I used Yeoman to create an Angular application with Grunt, NPM, and Bower etc. The PouchDB API says you can enable debugging like so:
PouchDB.debug.enable('*');
This however requires the node debug module to be installed. I have tried installing it via bower and referencing it in my index.html but to no avail. How do I inject the debug module into Angular? Or is this function only available when the PouchDB is ran from a Node.js server?
EDIT:
The exact error I am getting is bellow. The line it complains about is: PouchDB.debug.enable('*');
TypeError: Cannot read property 'enable' of undefined
at new <anonymous> (http://localhost:9000/scripts/services/taskdb.js:13:15)
at invoke (http://localhost:9000/bower_components/angular/angular.js:4129:17)
at Object.instantiate (http://localhost:9000/bower_components/angular/angular.js:4140:23)
at Object.<anonymous> (http://localhost:9000/bower_components/angular/angular.js:3998:24)
at Object.invoke (http://localhost:9000/bower_components/angular/angular.js:4129:17)
at Object.enforcedReturnValue [as $get] (http://localhost:9000/bower_components/angular/angular.js:3982:37)
at Object.invoke (http://localhost:9000/bower_components/angular/angular.js:4129:17)
at http://localhost:9000/bower_components/angular/angular.js:3947:37
at getService (http://localhost:9000/bower_components/angular/angular.js:4088:39)
at Object.invoke (http://localhost:9000/bower_components/angular/angular.js:4120:13)
angular.js:11413 TypeError: Cannot read property 'enable' of undefined
at new <anonymous> (http://localhost:9000/scripts/services/taskdb.js:13:15)
at invoke (http://localhost:9000/bower_components/angular/angular.js:4129:17)
at Object.instantiate (http://localhost:9000/bower_components/angular/angular.js:4140:23)
at Object.<anonymous> (http://localhost:9000/bower_components/angular/angular.js:3998:24)
at Object.invoke (http://localhost:9000/bower_components/angular/angular.js:4129:17)
at Object.enforcedReturnValue [as $get] (http://localhost:9000/bower_components/angular/angular.js:3982:37)
at Object.invoke (http://localhost:9000/bower_components/angular/angular.js:4129:17)
at http://localhost:9000/bower_components/angular/angular.js:3947:37
at getService (http://localhost:9000/bower_components/angular/angular.js:4088:39)
at invoke (http://localhost:9000/bower_components/angular/angular.js:4120:13) <div ng-view="" class="ng-scope">
When you use PouchDB, the debug module is already installed. You don't need to do anything except call PouchDB.debug.enable('*'). :)
Note that in PouchDB v7.0.0 loading a separate plugin is required for this.