Why does npm install say I have unmet dependencies?

I believe it is because the dependency resolution is a bit broken, see https://github.com/npm/npm/issues/1341#issuecomment-20634338 Following are the possible solution : Manually need to install the top-level modules, containing unmet dependencies: npm install findup-sync@0.1.2 Re-structure your package.json. Place all the high-level modules (serves as a dependency for others modules) at the bottom. Re-run the npm install … Read more

Can an AWS Lambda function call another

I found a way using the aws-sdk. var aws = require(‘aws-sdk’); var lambda = new aws.Lambda({ region: ‘us-west-2’ //change to your region }); lambda.invoke({ FunctionName: ‘name_of_your_lambda_function’, Payload: JSON.stringify(event, null, 2) // pass params }, function(error, data) { if (error) { context.done(‘error’, error); } if(data.Payload){ context.succeed(data.Payload) } }); You can find the doc here: http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html

Doing a cleanup action just before Node.js exits

UPDATE: You can register a handler for process.on(‘exit’) and in any other case(SIGINT or unhandled exception) to call process.exit() process.stdin.resume();//so the program will not close instantly function exitHandler(options, exitCode) { if (options.cleanup) console.log(‘clean’); if (exitCode || exitCode === 0) console.log(exitCode); if (options.exit) process.exit(); } //do something when app is closing process.on(‘exit’, exitHandler.bind(null,{cleanup:true})); //catches ctrl+c event … Read more

How can I change the version of npm using nvm?

As noted in another answer, there is now a command for this: nvm now has a command to update npm. It’s nvm install-latest-npm or nvm install –latest-npm. nvm install-latest-npm: Attempt to upgrade to the latest working npm on the current Node.js version. nvm install –latest-npm: After installing, attempt to upgrade to the latest working npm … Read more

NodeJS / Express: what is “app.use”?

The app object is instantiated on creation of the Express server. It has a middleware stack that can be customized in app.configure()(this is now deprecated in version 4.x). To setup your middleware, you can invoke app.use(<specific_middleware_layer_here>) for every middleware layer that you want to add (it can be generic to all paths, or triggered only … Read more

How can I set NODE_ENV=production on Windows?

Current versions of Windows use Powershell as the default shell, so use: $env:NODE_ENV=”production” Per @jsalonen’s answer below. If you’re in CMD (which is no longer maintained), use set NODE_ENV=production This should be executed in the command prompt where you intend to run your Node.js application. The above line would set the environment variable NODE_ENV for … Read more

Determine project root from a running node.js application

There are many ways to approach this, each with their own pros and cons: require.main.filename From http://nodejs.org/api/modules.html: When a file is run directly from Node, require.main is set to its module. That means that you can determine whether a file has been run directly by testing require.main === module Because module provides a filename property … Read more

Command to remove all npm modules globally

The following command removes all global npm modules. Note: this does not work on Windows. For a working Windows version, see Ollie Bennett’s Answer. npm ls -gp –depth=0 | awk -F/ ‘/node_modules/ && !/\/npm$/ {print $NF}’ | xargs npm -g rm Here is how it works: npm ls -gp –depth=0 lists all global top level … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)