LoginSignup
6
7

More than 5 years have passed since last update.

[備忘録] Node.js関係

Last updated at Posted at 2016-05-20

自分の環境

  • Node.js v5.4.0
  • npm 3.3.12
  • Express 4

npm start をforeverする方法

https://github.com/foreverjs/forever/issues/540

$ forever start -c "npm start" ./

絶対パスだと、失敗した。なんでじゃろ

80PortでNode.jsを動かすベストプラクティス(in Linux)

http://stackoverflow.com/questions/16573668/best-practices-when-running-node-js-with-port-80-ubuntu-linode

$ sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000

80portでlistenするのではなく、80portから3000portへRedirectさせることで実現する

Express4でのproduction環境への切り替え

$ export NODE_ENV=production && node app.js

development環境に戻す時はこう

$ export NODE_ENV=development && node app.js

最初の環境構築(AWS Linux)

// gitをインストール
$ sudo yum install git

// nvmをインストール && パスを通しておく
$ git clone git@github.com:creationix/nvm.git ~/.nvm
$ source ~/.nvm/nvm.sh

// Node.jsとnpmをインストール(Stable)
$ nvm install stable
6
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
7