Mon README de mes projets NodeJs

Voici un template de Readme que j'ai pour les projets en NodeJs:



# My project

## Introduction

Introduction of the project


## Development Commands

### npm start

Running the web server

```sh
npm start
```

If you want to change the NodeJs profile, you should override the system variable NODE_ENV

#### Windows

##### Command

```sh
set NODE_ENV=prod && npm start
```

##### PowerShell

```sh
$env:NODE_ENV="prod" ; npm start
```

#### Linux

```sh
NODE_ENV=prod npm start
```

### npm test

Running the associated unit tests

```sh
npm test
```

## Development Environment

We need to develop:

 - Git
 - NodeJs 4.3.0
 - NPM 2.14.12

---

### Credentials

With NPM and / or Bower, we will download from BitBucket some dependencies. So, the shell will ask to specify a login / password to retrieve the expected component.

However, you can automate that with the use of "netrc"

#### Step 1

Run

```sh
git config --edit --system
```

And remove with the vi editor the line "helper = manager" into the "[credential]" section

#### Step 2 - On Linux

Create into your $HOME a file named '.netrc'
Inject into the file:

````
machine bitbucket.org
login myBitbucketAccountEmail
password myBitbucketPassword

````

Run:

```sh
chmod 600 .netrc
```


#### Step 2 - On Windows

Run

```sh
setx HOME %USERPROFILE%
```

Create into your user folder (referenced by %USERPROFILE%) a file named '_netrc'
Inject into the file:

````
machine bitbucket.org
login myBitbucketAccountEmail
password myBitbucketPassword

````

---

### Install Git

#### Windows

Download https://git-for-windows.github.io/

#### Linux

```sh
sudo apt-get install git
```

#### All cases

Check if Git is available in the shell :

```sh
git version
```

If the command fails, add Git into the path. On Windows, use system variables and edit the PATH variable. On Linux, into the .bashrc file :

```sh
PATH=$PATH:path/to/git
```

#### Configure

We have at least set our name and email before committing and pushing on Git repositories. So, type the following command :

```sh
git config --global user.email "my.email@example.com"
git config --global user.name "My Name"
```


We can disable too the SSL verification for Git repositories with self-signed certificates :

```sh
git config --global http.sslVerify false
git config --global https.sslVerify false
```

This step can be ignored until we use a repository with a self-signed certificate.


Maybe we have to deal with a corporate proxy (this is not the case for the moment). So, we have to configure git with the following commands (we will use http://proxy.company.com:8080 as our corporate proxy) :

```sh
git config --global http.proxy http://proxy.company.com:8080
git config --global https.proxy http://proxy.company.com:8080
```

If needed, you can type the following command (to use https url instead git url. Usefwull when corporate firewall filter some protocols) :

```sh
git config --global url."https://".insteadOf git://
```

**If you want, you can set as system variable « HTTP_PROXY » and « HTTPS_PROXY » with the corporate proxy URL to share for many tools, like SVN, Git, NPM, Bower, …**
**There is too a « NO_PROXY » system variable to disable the proxy on the specified domains**

---

### Install NodeJs / NPM

#### Windows

Download https://nodejs.org/dist/v4.3.0/node-v4.3.0-x64.msi

#### Linux

> curl -sL https://deb.nodesource.com/setup_4.x | sudo bash -

> sudo apt-get install nodejs=4.3.0

#### Configure

We also can disable the SSL verification for NPM modules hosted on a self-signed certificate server :

```sh
npm config set strict-ssl false
```

This step can be ignored until we use a dependecy with a self-signed certificate.


Maybe we have to deal with a corporate proxy (this is not the case for the moment). So, we have to configure NPM with the following commands (we will use http://proxy.company.com:8080 as our corporate proxy) :

```sh
npm config set proxy http://proxy.company.com:8080
npm config set https-proxy http://proxy.company.com:8080
```

**If you want, you can set as system variable « HTTP_PROXY » and « HTTPS_PROXY » with the corporate proxy URL to share for many tools, like SVN, Git, NPM, Bower, …**


---

### Deal with corporate proxy

For Git, NPM and Bower, we can both use the following system variables:

 - HTTP_PROXY to declare a proxy for HTTP url
 - HTTPS_PROXY to declare a proxy for HTTPS url
 - NO_PROXY to disable the proxy management for the specified domains



Commentaires

Posts les plus consultés de ce blog

ISO: liens & outils utiles

NodeJs et SSL: une petite analyse

Créer sa commande slack en quelques minutes