This is the short and sweet version. If you find it helpful, you might want to check out the entire gist.
In your implementation, if you always do one of the following, you’ll be good to go, and you’ll provide a better experience for the people using your thing:
err => new Error()
Some kind of fatal error occurred– something where I’d normally throw. Except that I’m an asynchronous function. So instead, I do this:
return cb(new Error('Something bad happened!'));
This is like doing
throw new Error('Something bad happened!'); in a synchronous function. …
TL;DR — If you just installed a new version of Node, check your NPM version. If you’re using NPM v3.3.12 (the default for Node 5.5.0), you could run into issues when installing dependencies in your Sails app. Fortunately, NPM fixed this pretty fast, so all you should have to do is upgrade to the latest version of NPM (
npm install -g npm@latest) and everything will be hunky dory.
Version 3.0 of NPM (the Node Package Monger) significantly changed the way dependencies are saved in Node apps. Previously, your project’s
node_modules/ folder contained a deeply nested tree of subfolders, each representing a dependency of your project. …