nodejs

# null test

```
node
Welcome to Node.js v12.10.0.
Type ".help" for more information.
> test = 'aa' || 'bb' || null
'aa'
> test2 = 'aa' || null || 'bb'
'aa'
> test3 = null || 'aa' || 'bb'
'aa'
> test4 = null || null || 'aa'
'aa'
> test5 = null || 'aa' || null
'aa'
> test6 = 'aa' || null || null
'aa'
> test7 = null || null || null
```

#modules
##installation error
###Error: No compatible version found: chalk@'^0.4.0'
**error log**

```
npm ERR! error rolling back Error: ENOTEMPTY, rmdir '/Users/toripiyo/program/angularjs/logging/node_modules/nodemon/node_modules/ps-tree/node_modules'
npm ERR! error rolling back  nodemon@1.2.1 { [Error: ENOTEMPTY, rmdir '/Users/toripiyo/program/angularjs/logging/node_modules/nodemon/node_modules/ps-tree/node_modules']
npm ERR! error rolling back   errno: 53,
npm ERR! error rolling back   code: 'ENOTEMPTY',
npm ERR! error rolling back   path: '/Users/toripiyo/program/angularjs/logging/node_modules/nodemon/node_modules/ps-tree/node_modules' }
npm ERR! Error: No compatible version found: chalk@'^0.4.0'
npm ERR! Valid install targets:
npm ERR! ["0.1.0","0.1.1","0.2.0","0.2.1","0.3.0","0.4.0","0.5.0","0.5.1"]
npm ERR!     at installTargetsError (/Users/toripiyo/.nvm/v0.10.12/lib/node_modules/npm/lib/cache.js:719:10)
npm ERR!     at /Users/toripiyo/.nvm/v0.10.12/lib/node_modules/npm/lib/cache.js:641:10
npm ERR!     at saved (/Users/toripiyo/.nvm/v0.10.12/lib/node_modules/npm/node_modules/npm-registry-client/lib/get.js:138:7)
npm ERR!     at Object.oncomplete (fs.js:107:15)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>

npm ERR! System Darwin 13.3.0
npm ERR! command "/Users/toripiyo/.nvm/v0.10.12/bin/node" "/Users/toripiyo/.nvm/v0.10.12/bin/npm" "install"
npm ERR! cwd /Users/toripiyo/program/angularjs/logging
npm ERR! node -v v0.10.12
npm ERR! npm -v 1.2.32
npm http 304 https://registry.npmjs.org/lru-cache
npm http 304 https://registry.npmjs.org/sigmund
npm http 304 https://registry.npmjs.org/configstore
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/toripiyo/program/angularjs/logging/npm-debug.log
npm ERR! not ok code 0
```

**resolution**
update node version
http://anthonyfassett.blogspot.jp/2014/05/error-no-compatible-version-found.html

```
nvm install v0.10.29
nvm use v0.10.29
nvm alias default 0.10.29
npm install
```

## npm commands
- npm update:
    - npm checks if there exist newer versions in the repository that satisfy specified semantic versioning ranges and installs them.

##package
###nodemon
https://github.com/remy/nodemon
####usage

```zsh
#! /bin/zsh

_NODE_APP_PATH=~/program/angularjs/logging
_NODE_APP_BIN=${_NODE_APP_PATH}/node_modules/.bin
_NODE_MON_CMD=${_NODE_APP_BIN}/nodemon

case "$1" in
'start')
	(cd ${_NODE_APP_PATH}; ${_NODE_MON_CMD} --watch views -e js,jade app.js)
	;;
*)
	echo "Usage: $0 { start }"
	exit 1
	;;
esac
exit 0
```

### gulp
#### reload automatically if a file is modified
- install packages

```
npm install --save-dev gulp gulp-nodemon browser-sync
```

- create gulp.js file http://mid0111.hatenablog.com/entry/2015/08/19/200657

- do ```gulp``` command on application's home directory
- access ```localhost:4000``` through a browser.