w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Catch an error on requiring module in node.js
That works fine for me as you have it. Are you sure there's no node_modules/express folder somewhere above you in the filesystem that require is finding? Try doing this to be clear about what's happening: try { var express = require('express'); console.log("Express required with no problems", express); } catch (err){ console.log("Express is not installed."); //proceed to ask if they would like to install, or quit. //command to run npm install }

Categories : Javascript

node.js coffeescript - issues with requiring modules
myFunction is an instance method, so it won't be accessible directly from the class. If you want it as a class (or static) method, prefix the name with @ to refer to the class: class MyModule @myFunction : () -> # ... You can also export an Object if the intention is for all methods to be static: module.exports = myFunction: () -> # ... Otherwise, you'll need to create an instance, either in main: var utils = new Utils(); console.log(typeof utils.myFunction); Or, as the export object: module.exports = new Utils

Categories : Node Js

Node.js Error: Cannot find module express
You need to install Express locally into the context of your application (node_modules folder): $ npm install express The reason for this is that applications always look in their local context for any dependencies. The global installation is only for setting up system-wide available binaries, such as unit test runners or bootstrappers or things like that. With Express, when you install it globally, you get an express binary that can bootstrap an application for you. For more information, type $ express --help So, to answer your final question: YES, you need to install it without -g.

Categories : Node Js

npm package error - Cannot find module 'users-node'
Are you sure that you didn't install it with -g option? If so you need to set NODE_PATH environment variable. The default path for Windows is: %AppData%Roaming pm ode_modules In case you didn't install it globally, you must place your app.js file beside the node_modules directory which is created after you run npm install users-node

Categories : Node Js

Running UglifyJS under node.js generates cannot find module error
It seems that you've used node instead of uglify in the command line. Since uglifyjs is its own CLI, you don't need to call on node. I believe you need to have this installed globally to work as intended. npm install uglify-js -g then uglifyjs "path ouglifyjsinuglifyjs" -o "file.min.js" "file.js" should work.

Categories : Javascript

Cannot find module `mysql` node.js
It looks like you might be confused about how npm install works. npm install -g mysql will install globally not locally like you suggest. npm install mysql will install locally, putting the module in ./node_modules/mysql. This means the script you are running needs to be run from the same directory containing node_modules.

Categories : Mysql

node cannot find express module?
npm express -v doesn't show the version of Express that you have installed, it shows the version of npm. To show which version of Express you have installed, try this: npm ls express

Categories : Node Js

ruby gem, requiring a rails module bad practice?
I prefer to require as little as possible. See: http://guides.rubyonrails.org/active_support_core_extensions.html

Categories : Ruby On Rails

npm Cannot find module tobi-cookie; npm unable to install Express; Node.js
Nevermind, solved it with: git clone git://github.com/isaacs/npm.git cd npm/scripts chmod +x install.sh sudo ./install.sh from NPM, cannot find 'graceful-fs', no matter what I do and from NPM can't install appjs. Error: Cannot find module 'graceful-fs' then did /bin/npm install express -g /bin/npm install express

Categories : Node Js

Error in installing node.js module using npm
You need to add VCBuild.exe to your path. Check out this answer on how to do it: Testacular install failes, no vcbuild.exe

Categories : Node Js

How do I avoid SELF_SIGNED_CERT_IN_CHAIN error in node.js TLS module?
Does anybody know how to solve this error and create secure connections in node? For the case of Mac OS X, you need to put the root certificate (self signed, used for signing) in your Keychain.

Categories : Node Js

async module with c++ v8 for node js,error associated with the types in the structure
Your line *(request->result) = getArray(1); assigns a Handle<Array> to *(Handle<Array>) (which means Array*), which is not valid. However even with that, there is an important factor that you are not taking into account. Your wmiWorker function is running in a separate thread. NodeJS and V8 only allow a single thread of execution for JS, and what you are attempting to do is create a JS array inside of a separate thread. Instead you will need to create a vector or something, and generate the V8 array from that inside of the work callback's after_work callback.

Categories : Javascript

"Cannot switch to old mode now" - Node.JS apn module error in tls.connect function
Update: The behavior described below may have changed since this answer was originally written; as of 0.12.3, the docs suggest that you can now switch back and forth between paused (new) and flowing (old) mode, and that streams start out in paused mode. Also, "old" mistakenly suggests a deprecated way of doing things, but while the flowing mode came first, both are supported and have their uses. I don't have a specific answer, but a general explanation: The short of it: old code that calls .resume() or .pause() on readable streams can break on node 0.10 and higher. The long of it: You see this error on node 0.10 or higher when a readable stream has been initialized to use the new, paused mode (based on the readable event) and an attempt is later made to switch to the old, flowing mode

Categories : Javascript

In Javascript/Coffeescript how can I mock out a module's public variable in a test?
You want to use 'this' in that case, doSomething = function() { return alert(this.state); }; In your code, 'state' refers to the variable (via closure) which is undefined. You then return an object containing a new 'state' property. You don't need the first 'state' variable, but only the property in your returned object. 'this' in doSomething refers to whatever object it is a part of. In test3, doSomething refers to the returned object with 'state' set to undefined. Once you set state in test3, the object's 'state' property is no longer the same as the private variable 'state' in test2-- it is overwritten in test3. Essentially, you don't need the module pattern for the effect you desire, there's a much easier way: root.test2 = { state: void 0, doSomething: function() {

Categories : Javascript

Error: Cannot find module 'socket.io'
I think that you have executed the command npm install socket.io in a different location and your files are in different directory.. So either run the command in the same directory which have your files or either mention the path where you have currently installed socket.io in your PATH variable.

Categories : Node Js

Error: Can find module RSAGA
The most likely reason is that RSAGA doesn't know where SAGA is installed. Please include more detail, such as what system you have SAGA installed on, and what path it is installed to. Use rsaga.get.libraries() to see if any libraries are visible.

Categories : R

Coffeescript + Node.js : alternatives to callbacks
Look at async.js ( https://github.com/caolan/async ) It doesn't introduce new concepts, but allows you to streamline callback soup into something more manageable and readable. For example instead of foo(data, (err, result) -> bar( result, (err, omgimtired) -> foobar(omgimtired, (err....) -> ... ) ) ) You can just use async.waterfall and feed it a list of functions to call one after another. Promises are quite simple (if you manage to wrap your mind around them). They describe an object which is the result of a particular operation. Imagine that you return objects from all your functions, which represent results. Now imagine that every result has a function (then(...)) which is passed a callback for 'successful' completion and a callback for

Categories : Node Js

Run CoffeeScript class in browser and in node
In the general case it requires using libraries like requirejs and browserify, but in your case you can simply write: class classname constructor: (@arg)-> #code module?.classname = classname window?.classname = classname This code will check the existence of module and window variables before modifying them.

Categories : Javascript

TypeScript: tsc.exe --execute: Error cannot find module
Your code is fine. The -e flag is being removed from tsc, partly because it doesn't play nicely with this sort of scenario. Executing arbitrary JS in the context of the compiler process turns out to not be a good idea.

Categories : Node Js

How can I get rid of Error: Cannot find module 'models' on Heroku
You are missing "models" in the "dependencies" property of your package.json. (I checked the github repo). EDIT: sorry, looks like you are trying to use the module under /lib/models/ folder. So in this line https://github.com/gravityonmars/nodejs-starter/blob/master/index.js#L20 you can do this instead: require('./lib/models')(app);

Categories : Node Js

Why compilers are written in C/C++ instead of using CoffeeScript (JavaScript, Node JS)?
Compilers are very complex software in general. The front end part is pretty simple (parsing), but the backend part (scheduling, code generation, optimizations, register allocations) involve NP-complete problems (of course compilers try to approximate solutions to these problems). Thus, implementing in C would help compile times. C is also very good at bitwise operators and other low level stuff, which is useful for writing a compiler. Note that not all compilers are written in C though. For example, Haskell GHC compiler is written in Haskell using bootstrapping technique. Javascript is async, which doesn't suit compiler writing.

Categories : C

Coffeescript + node.js : Unexpected token > (function arrow)
When I looked for coffeescript's version on the terminal, it couldn't find it. So I exported coffescript's path by adding the following line to bashrc: export PATH=/usr/local/share/npm/lib/node_modules/coffee-script/bin/:$PATH This resolved the issue

Categories : Javascript

How do I replace a node with an image using D3 and CoffeeScript for a network visualization?
You can't use images like that directly in SVG, you need to define them as a pattern. See this question for more information. You haven't shown us your code, but I suspect that this is the source of your problem. What you need to do is append a pattern for each image you need to the defs section of the SVG and then reference those patterns when you add the node. The code would look something like this. defs = svg.append("defs") defs.selectAll("pattern") .data(curNodesData) .append("pattern") .attr("id", (d) -> d.group) .append("image") .attr("xlink:href", (d) -> d.group) You may need to set the dimensions for the patterns and images. Then later you can do the following node.enter().append("circle") .attr("fill", (d) -> "url(#" + d.group + ")") You ma

Categories : Javascript

NodeJS gives Cannot find module './parser' error while running Handlebars
For simplicity reasons: Just download all the necessary packages on a PC with internet access (so actually just run npm install in the handlebars folder) and then just copy the folder with all the modules

Categories : Javascript

Application error in Windows event log, faulting module name is unknow, why?
The only way that the faulting module could be known is when the exception is caused by executing code in a memory address that "belongs" to a particular module (Probably based on the module's loaded address). So one way that the module could be unknown is if an application is dereferencing a pointer that is NULL or contains random data. That way it will attempt to execute code from some undefined location that cannot be tied to a particular module.

Categories : Windows

Drupal module node type creation .install vs .module
you can create node_types using both node_type_save() and hook_node_info(). Drupal Core book module creates it in hook_install. But its more common practice to do so in hook_node_info() or hook_entity_info() ( node module uses hook_entity_info() ). if you implement using hook_node_info() you are more complaint with the way drupal works. For example node_type_rebuild() will only work with values defined in hook_node_info() and not node_type_save(). Imo you should be using hook_node_info() or hook_entity_info() and let drupal core handle the rest.

Categories : Drupal

Error: Cannot find module 'underscore' thrown in console for all Meteor commands
First off, your meteorite is out of date. To update meteorite run (sudo if applicable): npm update -g meteorite If you ran the 'mrt' or 'meteor' command as sudo in the past, it will cause issues. Clear meteorite by running: sudo mrt uninstall sudo mrt uninstall --system sudo chown -R `whoami` ~/.npm You also want to remove the 'build' folder inside existing projects, located in '/project/.meteor/local/build'

Categories : Javascript

basic coffeescript find if in array
Just drop the is: if $(this).val() in ["needs_cover","comatose"] $("#head_count").hide() else $("#head_count").show() That would translate to the following JavaScript: var _ref; if ((_ref = $(this).val()) === "needs_cover" || _ref === "comatose") { $("#head_count").hide(); } else { $("#head_count").show(); }

Categories : Javascript

adapting Coffeescript for a rails application
First of all, the "CoffeeScript" that js2coffee produced is, as expected, pretty terrible CoffeeScript. It is pretty obvious that a piece of software just transliterated from one language to another without understanding what the code was really doing. I'd strongly recommend that you learn JavaScript (and CoffeeScript if desired) if you're going to be doing any web development at all. Now into the code. The function breakdown is fine but what's inside the functions is overly complicated. You don't need to keep track of row_i in a global variable, you don't even have to keep track of it at all as you can always compute the indexes you need; so we'll throw that out and pretend it never happened. Your main HTML should look more like this: <table class="student_input_form"> <t

Categories : Jquery

how to find out the exact name of error thrown in mysql node.js
this.addReservation = function(req, res, next) { var json = JSON.parse(req.body['reservation']); var post = {user1: json.player1, user2: json.player2, courtId: json.id, hour: json.hour, date: json.date}; var giveback = {u1_first: req.user.firstName, u1_last: req.user.lastName, user1: json.player1, user2: json.player2}; connection.query('insert into ordering set ?', post, function(err, result){ if (err){ console.log('exact name of error thrown '+err); return res.send(500); } else return res.json({res: giveback}) //return res.send(200); }); };

Categories : Javascript

Application Error : express and socket.io with node.js in heroku
You don't need to call createServer twice. Just 1 createServer and 1 listen. var express = require('express'); var app = express() , http = require('http') , server = http.createServer(app) , io = require('socket.io').listen(server); server.listen(process.env.PORT, process.env.IP);

Categories : Node Js

Requiring sikuli gem throwing an error
As per my knowledge n if we want to use gem 'sikuli' You need java setup on your machine 'Sikuli' works with jruby , so install jruby and go to jruby's IRB, and hit "require 'Sikuli' " You can check details here Link-1 Link-2

Categories : Ruby

Kendo UI treeview find the next node and previous node of the selected node
You should use jQuery next and prev for getting the nodes. You can use: var sel = treeview.select(); var next = $(sel).next(); var prev = $(sel).prev(); Where: treeview is the treeview object (i.e. $("#grid").data("kendoTreeView")) sel is current selected node, next is next node. and prev previous node. If you need to get the item in the model you should use treeview.dataItem with sel, next or prev as argument.

Categories : Kendo Ui

How To Require Node Module In Node REPL Without Installing Globally?
Printing undefined is normal behavior for both the browser console and the node repl. Try typing: express. (tab key) - you should get something like this: > var express = require('express'); undefined > express. express.__defineGetter__ express.__defineSetter__ express.__lookupGetter__ express.__lookupSetter__ express.constructor express.hasOwnProperty express.isPrototypeOf express.propertyIsEnumerable express.toLocaleString express.toString express.valueOf express.apply express.arguments express.bind express.call express.caller express.constructor express.length express.name express.toString

Categories : Node Js

Coffeescript class find or create mongo document
I think you're confused about the meaning of @ at the class level. A simplified example should help, this CoffeeScript: class B @p: 'b' is the same as this JavaScript: var B = (function() { function B() {} B.p = 'b'; return B; })(); So you can see that p is a class property that is directly attached to the C class/function. But when you're inside a method, such as constructor, @ refers to the instance so, in your case, @collection will be undefined because you're defining collection as a class property. You probably want collection to be an instance property: class MongoObject collection: undefined constructor: (id) -> # @collection is what you expect it to be in here class TextObject extends MongoObject collection: 'TextObject' Demo: http://jsfi

Categories : Javascript

'error during type inferencing' in eclipse when developing node.js application
If the error is still there as of Nodeclipse 0.7, raise an issue on https://github.com/nodeclipse/nodeclipse-1/ and give some information needed as mentioned on http://www.nodeclipse.org/#support

Categories : Eclipse

Node.js node-apn module for Apple Push Notification stopped working after moving to Amazon EC2 instance running Ubuntu 12.04
Check your node --version s. On my Mac, homebrew installed v0.10.12 but on the server I was running v0.11.8-pre (by mistake). Apparently the present node-apn doesn't work under the unstable. I had this same extremely frustrating issue and hunted among firewalls/OpenSSH stuff until I realized the APNS connection still worked through PHP. The Ray Wenderlich script is a quick way to check if the problem is with node or elsewhere.

Categories : Node Js

some coffeescript not working, possibly related to application.js and/or javascript plugins
Maybe because of these lines? //= require jquery ... //= require static_pages //= require jquery191 Try remove line //= require jquery191? Or replace jquery with it. Or inculde static_pages at last.

Categories : Javascript

Requiring help identifying error in chess JavaScript code
You seem to use === everywhere, even where you mean to assign values instead of comparing them. Go through the code and change === to = where you assign values, e.g.: if (file === "a" || file === "h") { // comparison, === is ok defClass = "brook"; // assignment, use single = instead defValue = brookValue; // --"-- } and so on. The next problem is that you assign string values but strictly compare to numbers, which is going to be false every time: rank = "8"; // ..later: if (rank === 8) {

Categories : Javascript

Node.js + Node-Webkit + Node-SerialPort Based Application - Is this Possible?
That's what most people use Node.js for https://npmjs.org/search?q=serial+port Again, that's what most people use Node.js for Because of 1 and 3, the most obvious UI for node.js apps is the browser. Write a config page to control your app. Using node-webkit is overkill, just use whatever browser is already available. Node can run multiple listeners on multiple ports, serving the same app. npm install is pretty simple. Go learn how to write simple Node.js apps (with express for easy http servering, and jade or nunjucks for easy html templating) and then move up from there.

Categories : Javascript



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.