FAQ Database Discussion Community


Why does the “request module” in Node.js accept only the URLs written with protocol?

node.js,http,get,protocols,node-modules
I want to send a GET request using request module. Here's the code: var requestModule = require('request'); var url = require('url'); var myUrl = 'www.google.com'; var myUrlObj = url.parse(myUrl); requestModule(myUrl, myUrlObj , callback); but it doesn't work because myUrlObj has a null value for its "protocol" attribute. The same code...

Gulp didn't install on Laravel Homestead VM (from Windows) and no node_modules folder exists in the directory with package.json?

laravel,gulp,node-modules,homestead,laravel-elixir
I got Laravel Homestead up and running, except when I issue this ssh command: gulp I get this error: Local gulp not found in ~/projects/laravel Try running: npm install gulp That's when I noticed there was no node_modules folder at all in this directory. Weird. Is this an issue where...

pass optional parameters to require()

node.js,node-modules
so, I have this problem - and when I have a problem with JavaScript or node inevitably it is my coding that is the problem ;) So at the risk of ridicule, this is the problem: I have a module that has an optional parameter for config Using the standard...

Importing Sass through npm

node.js,sass,npm,node-modules
Currently in our Sass files we have something like the following: @import "../../node_modules/some-module/sass/app"; This is bad, because we're not actually sure of the path: it could be ../node_modules, it could be ../../../../../node_modules, because of how npm installs stuff. Is there a way in Sass that we can search up until...

Using the shell provided with NodeJS

javascript,node.js,shell,require,node-modules
Once you've installed NodeJS, you'll have a executable in your computer named NodeJS which is a shell. I was wondering what can I do with that... here you're able to run JS code as, for example, in the browser's console, great. Now, is it possible to require modules in that...

Why won't Git add/commit files when node_modules folder isn't ignored in .gitignore?

php,git,laravel,github,node-modules
The question I can't add or commit with git when node_modules isn't ignored in the .gitignore file. When it is, everything works just fine. Why is this? I do not understand and it bugs me. Is it ok not to upload the node_modules folder? I push and deploy to Amazon...

Restoring node-modules and bower_components based on script contents

node.js,npm,bower,node-modules
How do I restore node-modules and bower_components? A bit of context: I'm planning to only source control the files which are actually part of my application and not the dependencies. What I want is to restore those dependencies after I clone a fresh copy of my project. What I want...

What happens to modules required in exported modules Node?

node.js,node-modules
I've been trying to modularize my server and web apps. i've read about exports and module.exports in Node here and here. http://www.sitepoint.com/understanding-module-exports-exports-node-js/ http://liangzan.net/blog/blog/2012/06/04/how-to-use-exports-in-nodejs/ I get how it makes the functions available to other files / scripts, but what happens to the modules required within the exported file? If I require...

Cordova 4.3.0 - build command returns error Cannot find module 'Q'

xcode,cordova,npm,node-modules,cordova-cli
After updating cordova to version 4.3.0 the command: cordova build returns the following error: module.js:340 throw err; ^ Error: Cannot find module 'Q' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:364:17) at require (module.js:380:17) at Object.<anonymous> (/Volumes/CaseSensitive/ios_projects/_Tests/testGruntCordova/testGruntCordova/platforms/ios/cordova/lib/check_reqs.js:25:13) at Module._compile (module.js:456:26) at Object.Module._extensions..js...

Bluebird promise `promisifyAll` not working - cannot read property `then`

xml-parsing,callback,promise,bluebird,node-modules
I am using a node module that uses the node callback convention. I wants to convert this module into an API using Bluebird promises. I am not getting how to do this. Below is my node style callback function. I wants to convert it into thenable promise of bluebird. var...

export javascript function using React

javascript,html,node.js,reactjs,node-modules
I am trying to do the facebook login for a website. What I post is a segment of a js file with a render function that returns this html code: var hellojs = require('./hello.js'); // See what hello.js does: http://adodson.com/hello.js/demos/profile.html#helloapi-me- //It basically prompts the facebook window to sign up. var...

Why does a module level return statement work in Node.js?

javascript,node.js,return,syntax-error,node-modules
When I was answering another question I came across a Node.js module with a top-level return statement. For example: console.log("Trying to reach"); return; console.log("dead code"); This works without any errors and prints: Trying to reach in the standard output but not "dead code" - the return actually ceased execution. But...