How can I update NodeJS and NPM to their latest versions?

I just installed Node.js & NPM (Node Package Manager) I installed NPM for access to additional Node.js Modules. After I installed Node.js & NPM I noticed that neither were the latest versions available. I would like to know: How do I upgrade Node.js, NPM, and my Node.js Modules to their latest versions? Do I need … Read more

Do I commit the package-lock.json file created by npm 5?

npm 5 was released today and one of the new features include deterministic installs with the creation of a package-lock.json file. Is this file supposed to be kept in source control? I’m assuming it’s similar to yarn.lock and composer.lock, both of which are supposed to be kept in source control. 12 Yes, package-lock.json is intended … Read more

How to exit in Node.js

What is the command that is used to exit? (i.e terminate the Node.js process) 2 22 Call the global process object’s exit method: process.exit() From the docs: process.exit([exitcode]) Ends the process with the specified code. If omitted, exit uses the ‘success’ code 0. To exit with a ‘failure’ code: process.exit(1); The shell that executed node … Read more

Using async/await with a forEach loop

Are there any issues with using async/await in a forEach loop? I’m trying to loop through an array of files and await on the contents of each file. import fs from ‘fs-promise’ async function printFiles () { const files = await getFilePaths() // Assume this works fine files.forEach(async (file) => { const contents = await … Read more

Find (and kill) process locking port 3000 on Mac [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it’s on-topic for Stack Overflow. Closed 3 months ago. Improve this question How do I find (and kill) processes that listen to/use my TCP ports? I’m on macOS. Sometimes, after a … Read more

What’s the difference between dependencies, devDependencies and peerDependencies in npm package.json file?

This documentation answers my question very poorly. I didn’t understand those explanations. Can someone say in simpler words? Maybe with examples if it’s hard to choose simple words? EDIT also added peerDependencies, which is closely related and might cause confusion. 1 17 Summary of important behavior differences: dependencies are installed on both: npm install from … Read more