Signup/Sign In

Answers

All questions must be answered. Here are the Answers given by this user in the Forum.

*npm view version* - returns the latest available version on the package.

*npm list --depth=0* - returns versions of all installed modules without dependencies.

*npm list* - returns versions of all modules and dependencies.

And lastly to get node version: node -v
3 years ago
There are a lot of details in the File System API. The most common way is:
***
const fs = require('fs');

fs.writeFile("/tmp/test", "Hey there!", function(err) {
if(err) {
return console.log(err);
}
console.log("The file was saved!");
});

// Or
fs.writeFileSync('/tmp/test-sync', 'Hey there!');
***
3 years ago
You can simply install stable by following the commands below:
***
nvm ls-remote
nvm install
nvm use
***
3 years ago
Instead of Promise.all in conjunction with Array.prototype.map (which does not guarantee the order in which the Promises are resolved), I use Array.prototype.reduce, starting with a resolved Promise:
***
async function printFiles () {
const files = await getFilePaths();

await files.reduce(async (promise, file) => {
// This line will wait for the last async function to finish.
// The first iteration uses an already resolved Promise
// so, it will immediately continue.
await promise;
const contents = await fs.readFile(file, 'utf8');
console.log(contents);
}, Promise.resolve());
}
***
3 years ago
To remove:

brew uninstall node;
***
# or `brew uninstall --force node` which removes all versions
brew cleanup;
rm -f /usr/local/bin/npm /usr/local/lib/dtrace/node.d;
rm -rf ~/.npm;
***
To install:
***
brew install node;
which node # => /usr/local/bin/node
export NODE_PATH='/usr/local/lib/node_modules' # <--- add this ~/.bashrc
***
You can run brew info node for more details regarding your node installs.
3 years ago