HiFaraz / node-playbook
- вторник, 30 августа 2016 г. в 03:14:37
277 stars today
Get started fast with Node.js
This is a opinionated "get started" guide to developing with Node.js.
You waste time by:
Follow this playbook. It recommends basic choices that let you focus on writing code instead of setting things up.
Each solution was chosen after balancing:
Be optimally lazy. There are only two principles:
This section covers general problems regardless of your development goals.
Many versions are listed on the Node.js website. Choosing a Node.js version wastes time.
Choose Node.js v6. It will enter long term support (LTS) on October 1, 2016, after which it will stay in LTS for 18 months. This gives you peace of mind against major new features popping up in Node.js while you build your app.
Choosing a development environment (e.g. editors, git GUIs, terminals, FTP clients) wastes time. No tool is 10 times better than another. You need a set of tools that get you started and let you grow according to you needs.
Download and install these tools:
Settings > Packages
and enable Beautify On Save
for CSS, HTML, JavaScript, JSON, and Markdown)Ctrl+P
in the editor to open the preview)Ctrl+Shift+M
in the editor to open the preview)Thinking about how to set up a new project wastes time.
npm init
in your terminal to create a package.json
file
MIT
when prompted for a license nameatom ./
in your terminal to launch Atom in your project folderThinking about how to set up your project file and folder structure wastes time.
source
: place all your source code heretest
: place all testing code herebuild
(optional): use this as a destination folder if/when you implement a build system (something that converts your source code to another form)source
sub-folder called index.js
Fretting over coding style wastes time, and a sloppy coding style reflects poorly on you. You need a coding style that looks decent and is easy to follow.
Follow Airbnb's Javascript Style Guide
Some npm packages do not install on Windows because they contain non-JavaScript code. You will see errors related to node-gyp
when you try to install them.
Find another npm package that does the job in pure JavaScript. For example, bcryptjs is a drop-in replacement for the popular bcrypt module.
How to find alternatives:
Make sure that your chosen alternative is a suitable replacement. Look for:
This is the simplest solution as it eliminates the problem rather than trying to accommodate it. The speed advantage from the native module will not be missed until later in your development cycle.
Do this if and only if you cannot find a suitable alternative npm package.
Follow the Windows installation instructions at the node-gyp README.
I never got this to work despite many tries.
This section covers problems commonly encountered with developing, deploying, and distributing web applications.
Choosing a technology stack (e.g. server framework, database, front-end framework, hosting platform) wastes time. Every stack is different and affects your project, however this is mostly a matter of style. Every stack will do the job.
This section covers problems commonly encountered with developing and publishing reusable packages.
Deciding on a version number scheme wastes time. Using a non-standard scheme confuses anyone using your package.
Use Semantic Versioning (a.k.a. semver). Here are the most important bits to get started:
Given a version number MAJOR.MINOR.PATCH, increment the:
- MAJOR version when you make incompatible API changes,
- MINOR version when you add functionality in a backwards-compatible manner, and
- PATCH version when you make backwards-compatible bug fixes.
How should I deal with revisions in the 0.y.z initial development phase?
The simplest thing to do is start your initial development release at 0.1.0 and then increment the minor version for each subsequent release.
How do I know when to release 1.0.0?
If your software is being used in production, it should probably already be 1.0.0. If you have a stable API on which users have come to depend, you should be 1.0.0. If you’re worrying a lot about backwards compatibility, you should probably already be 1.0.0.
This section covers problems commonly encountered with:
I am seeking contributors for this section.
This section covers problems commonly encountered with developing and distributing desktop applications.
I am seeking contributors for this section.
Deciding which cross platform framework to use is a waste of time.
Use Electron. It is now considered stable as version 1 was released on May 11, 2016. It is backed by the makers of GitHub and Atom, and has a strong community. Electron apps build and run on Mac, Windows, and Linux.
Contributions are welcome through GitHub Issues! Please contribute by:
MIT License
Copyright (c) 2016 Faraz Syed
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.