javascript - nodejs - best practices

nodejs - best practices

sindresorhus/awesome-nodejs -

ryanmcdermott/clean-code-javascript -

i0natan/nodebestpractices -

Node.js Best Practices : Matt Goldspink 20160829

  • Start all projects with npm init
  • Setup .npmrc
  • Add scripts to your package.json
  • Use environment variables
  • Use a style guide
  • Embrace async
  • Handle errors
  • Ensure your app automatically restarts
  • Cluster your app to improve performance and reliability
  • Require all your dependencies up front
  • Use a logging library to increase errors visibility
  • Use Helmet if you’re writing a web app
  • Monitor your applications
  • Test your code

Node.js Best Practices - How to Become a Better Developer in 2017 :

switching node version between projects


nvm vs n! - .gitignore - 20170522

How I manage multiple Node.js versions - - 20160719

The Best Way to Install Node.js - - 20180929

tooling comparison

Taken from stackoverflow answer from nvm maintainer

The most-used version managers for node are without a doubt,, and

nvm is for modifying individual shell sessions to use the version you want. nave is for launching subshells with the version you want loaded. n is for switching a single system-wide version of node.

nvm uses a .nvmrc file, which like .ruby-version, contains the version-ish string X you'd normally couple with nvm use X or nvm install X. nvm use or nvm install by itself will locate the .nvmrc file, as will simply sourcing nvm upon opening a new shell.

It appears nave supports a .naverc file, but I'm not too familiar with its usage.

n doesn't appear to support any such config, but as it's system-wide, it doesn't really make as much sense to do so.

avn supports .node-version and attempts to provide automatic version switching by hooking into cd, after nvm decided that was too invasive a behavior to include.


creationix/nvm -

NVM Automatic Switching : gist


tj/n -

Node.js version management: no subshells, no profile setup, no convoluted API, just simple.


Super easy but system wide.

List installed version


Output :

ο 0.8.17

Change the active version by selecting the line and hit space bar.

Install desired node version with n <version> ex n 10.2.1.


Possible issue with npm, any npm command will output this :

npm WARN lifecycle npm is using /home/<HOME_DIR>/n/bin/node but there is no node binary in the current PATH. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.

Fixed by adding a .npmrc file in the project root dir containing :


node package with npx

using a node package inside package.json

cf tweet

app structure

STRUCTURER MA PREMIÈRE APPLICATION NODEJS - RemixJobs - François-Guillaume Ribreau et Julien Breux - 20160726

  • DRY sur le config projet (eslint, code quality, etc ...)
  • automatisation des conventions
  • 12 factors
  • logging
  • swagger
  • unit / functionnal testing
  • CI (circle & jenkins)
  • deploy
  • health checking
  • métriques métiers

Advanced Node.js Project Structure Tutorial - 20180508


The Best Node.js & Microservices Articles we Ever Wrote - - 20180516

Node.js - File System -

  • Synchronous vs Asynchronous
  • Open a File
  • Flags
  • Get File Information
  • Writing a File
  • Reading a File
  • Closing a File
  • Truncate a File
  • Delete a File
  • Create a Directory
  • Read a Directory
  • Remove a Directory

results for ""

    No results matching ""