https://docs.npmjs.com/getting-started/updating-global-packages
#NPM을 통해서 다운받았던 글로벌 패키지들을 업데이트합니다.
링크에 나와있는 내용을 기반으로 업데이트를 진행해봤습니다.
사용하는 모듈이 최신버전이 아닐경우 문제가 생기는 경우가 간혹 있어서
업데이트하는 방법을 찾아봤는데 어렵지 않더라구요.
공유합니다.
$npm updated -g
#Update these outdated list
$npm update -g
2016년 7월 28일 목요일
2016년 5월 2일 월요일
Node.js Expressjs error, payload too large
I have some error
using Node.js + expressjs
Error message : payload too large
Detail message (on front-end browser):
Failed to load resource: the server responded with a status of 413 (Payload Too Large)
This error can fix it with simple code.
add limit option to
bodyParser.json({})
bodyParser.urlencoded({})
I hope you save time
using Node.js + expressjs
Error message : payload too large
Detail message (on front-end browser):
Failed to load resource: the server responded with a status of 413 (Payload Too Large)
This error can fix it with simple code.
add limit option to
bodyParser.json({})
bodyParser.urlencoded({})
I hope you save time
2016년 4월 12일 화요일
Node.js + Express.js + Bootstrap(부트스트랩) 시작하기
부트스트랩을 Node.js 서버랑 사용해보기!
튜토리얼 시작해보겠습니다.
우선 이 튜토리얼은 Node.js가 설치되어있다는 가정하에 시작하겠습니다.
그리고 Express를 사용하기 위해서 설치해야 하는 것,
express-generator입니다. (꼭 설치해야한다는 것 보다, 프로젝트 만들기 편합니다.)
express-generator 설치해줍니다.
$npm install express-generator -g
다 설치가 되었다면,
express 명령어로 프로젝트를 생성해줍니다.
$express -e myproject
여기서, express -h로 express 명령어의 help를 보겠습니다.
Usage: express [options] [dir]
Options:
-h, --help output usage information
-V, --version output the version number
-e, --ejs add ejs engine support (defaults to jade)
--hbs add handlebars engine support
-H, --hogan add hogan.js engine support
-c, --css
--git add .gitignore
-f, --force force on non-empty directory
-e 의 의미는 ejs 엔진을 사용하겠다는 옵션입니다.
ejs는 Embeddedjs로 http://www.embeddedjs.com/
위의 링크에서 자세한 내용을 보실수 있을겁니다.
자, 다시 프로젝트를 만든 시점에서
아래와 같은 출력을 볼 수 있을겁니다.
create : myproject
create : myproject/package.json
create : myproject/app.js
create : myproject/public/javascripts
create : myproject/routes
create : myproject/routes/index.js
create : myproject/routes/users.js
create : myproject/public
create : myproject/public/images
create : myproject/views
create : myproject/views/index.ejs
create : myproject/views/error.ejs
create : myproject/public/stylesheets
create : myproject/public/stylesheets/style.css
create : myproject/bin
create : myproject/bin/www
install dependencies:
> cd myproject && npm install
run the app:
> SET DEBUG=myproject:* & npm start
위에 나온 install dependencies를 따라해봅시다.
$cd myproject && npm install
출력>
+-- body-parser@1.13.3
| +-- bytes@2.1.0
| +-- content-type@1.0.1
| +-- depd@1.0.1
| +-- http-errors@1.3.1
| | +-- inherits@2.0.1
...
다 설치됬습니다.
실행해볼까요?
$npm start
결과 페이지는 다음과 같습니다.
텅 비어있는 기본페이지 입니다.
저희는 여기에 부트스트랩을 끼얹어볼거에요.
부트스트랩 받아봅니다.
http://bootstrapk.com/getting-started/#download
npm, bower 사용해서 다운받을 수 있지만 저희는
CDN(Content Delivery Network)에 있는 부트스트랩을 사용해보겠습니다.
myproject/views/index.ejs를 아래와 같이 수정해줍니다.
수정된 화면은 아래와 같습니다.
부트스트랩 기본 예제에서 가져온 코드입니다.
http://bootstrapk.com/examples/jumbotron/
부트스트랩을 다운받아서 사용하지 않고 인터넷에서 받아서 사용했는데
다음 포스팅에서는 다운받아서 사용하는 방법을 소개해보겠습니다.
감사합니다
2016년 3월 24일 목요일
Nightwatch.js
Nightwatch.js
Nightwatch.js GitHub: https://github.com/nightwatchjs/nightwatch
Nightwatch.js is testing solution.
In nightwatch homepage say:
"Nightwatch.js is an automated testing framework for web applications and websites, written in Node.js and using the Selenium WebDriver API."
- Guide
Guide : http://nightwatchjs.org/guide
- Install
//install nightwatch
$npm install nightwatch
//install selenium server
$wget http://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.0.jar
//runing
$java -jar selenium-server-standalone-2.53.0.jar
11:47:47.404 INFO - Launching a standalone Selenium Server
11:47:47.690 INFO - Java: Oracle Corporation 25.60-b23
11:47:47.690 INFO - OS: Windows 8.1 6.3 x86
11:47:47.819 INFO - v2.53.0, with Core v2.53.0. Built from revision 35ae25b
11:47:48.155 INFO - Driver class not found: com.opera.core.systems.OperaDriver
11:47:48.155 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
11:47:48.169 INFO - Driver provider org.openqa.selenium.safari.SafariDriver registration is skipped:
registration capabilities Capabilities [{browserName=safari, version=, platform=MAC}] does not match the current platform WIN8_1
11:47:48.170 INFO - Driver class not found: org.openqa.selenium.htmlunit.HtmlUnitDriver
11:47:48.170 INFO - Driver provider org.openqa.selenium.htmlunit.HtmlUnitDriver is not registered
11:47:49.851 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
11:47:49.851 INFO - Selenium Server is up and running
//help selenium server
$java -jar selenium-server-standalone-2.53.0.jar -help
- Configure
//file setting, nightwatch.json
- In my test
1. Start selenium server
$java -jar selenium-server-standalone-2.53.0.jar
2. Start nightwatch
##Before start nightwatch##
$npm install nightwatch -g
$mkdir nightwatch-test
$cd nightwatch-test
$npm install nightwatch
$cp -r node_modules/nightwatch/examples .
##End##
//Do tests
$nightwatch
[Digg] Test Suite
=================
digg module is disabled, skipping...
[Github] Test Suite
===================
Running: Demo test GitHub
Error retrieving a new session from the selenium server
{ state: 'unhandled error',
sessionId: null,
hCode: 17478365,
value:
{ buildInformation:
{ buildRevision: '35ae25b',
buildTime: '2016-03-15 17:00:58',
releaseLabel: '2.53.0',
hCode: 87554,
class: 'org.openqa.selenium.internal.BuildInfo' },
cause: null,
systemInformation: 'System info: host: \'pineoc-pc\', ip: \'192.168.99.1\', os.name: \'Windows 8.1\', os.arch: \'x86\', os.version: \'6.3\', java.version: \'1.8.0_60\'',
additionalInformation: '\nDriver info: driver.version: FirefoxDriver',
screen: null,
suppressed: [ [length]: 0 ],
class: 'org.openqa.selenium.WebDriverException',
localizedMessage: 'Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: WIN8_1\nBuild info: version: \'2.53.0\', revision: \'35ae25b\', time: \'2016-03-15 17:00:5
8\'\nSystem info: host: \'pineoc-pc\', ip: \'192.168.99.1\', os.name: \'Windows 8.1\', os.arch: \'x86\', os.version: \'6.3\', java.version: \'1.8.0_60\'\nDriver info: driver.version: FirefoxDriver',
supportUrl: null,
message: 'Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: WIN8_1\nBuild info: version: \'2.53.0\', revision: \'35ae25b\', time: \'2016-03-15 17:00:58\'\nSyst
em info: host: \'pineoc-pc\', ip: \'192.168.99.1\', os.name: \'Windows 8.1\', os.arch: \'x86\', os.version: \'6.3\', java.version: \'1.8.0_60\'\nDriver info: driver.version: FirefoxDriver',
hCode: 5692872 },
class: 'org.openqa.selenium.remote.Response',
status: 13 }
Connection refused! Is selenium server started?
...
install firefox please.
I will return install firefox next time.
2016년 2월 24일 수요일
Node.js monitoring tool + managing tool "PM2"
GitHub: https://github.com/Unitech/pm2
official site: http://pm2.keymetrics.io/
Install
$npm install pm2 -g
Start
$pm2 start app.js
more informations on GitHub
2016년 2월 1일 월요일
Node.js Express4 make https server
Make https server using Node.js + Expressjs v4
1. Make expressjs project
$express https_server
$cd https_server && npm install
2. Make cert, key file
$openssl genrsa 1024 > key.pem
using this key.pem file, make cert file.
$openssl req -x509 -new -key key.pem > cert.pem
Insert these data.
- Country Name
- State or Province Name
- Locality Name
- Organization Name
- Organization Unit Name
- Common Name
- Email Address
cert, key file ready to make https server.
3. Edit server code
(bin/www file code)
4. Run
$npm start
(if you occur error, please run on root)
Good luck!
ps1. bin/www file code added part
https://gist.github.com/pineoc/b1d9c31e5e0600d328fc#file-https-server-bin-www-js-L95-L111
ps2. file dir tree image
2016년 1월 27일 수요일
Webstorm require unresolved warnings
Warning is this
Warning delete simple
My Webstorm version is 11.0.3
preferences-> Languages & Frameworks -> Node.js and NPM
Code Assistance
Node.js Core library enable
Enable!
And you will can not see the warnings 'require'
2016년 1월 25일 월요일
node-apn muti push
Using node-apn
Multi push to devices
node-apn link: https://github.com/argon/node-apn
GitHub example on node-apn :
https://github.com/argon/node-apn/blob/master/examples/sending-to-multiple-devices.js
GitHub example on node-apn :
https://github.com/argon/node-apn/blob/master/examples/sending-to-multiple-devices.js
mongo-express, const error
C:\Users\test\AppData\Roaming\npm\node_modules\mongo-express\app.js:5
const clc = require('cli-color');
^^^^^
SyntaxError: Use of const in strict mode.
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
This error occur on node.js v0.10.x
Update node.js version to 4.x OR 5.x
and will be no error.
good luck
const clc = require('cli-color');
^^^^^
SyntaxError: Use of const in strict mode.
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
This error occur on node.js v0.10.x
Update node.js version to 4.x OR 5.x
and will be no error.
good luck
2016년 1월 18일 월요일
MEAN stack
MEAN stack
http://mean.io/#!/
https://github.com/linnovate/mean/
MEAN stack means MongoDB + Express.js + Angular.js + Node.js
Start for MEAN stack
http://learn.mean.io/#mean-stack
- start install
//prerequisite packages
$npm install -g gulp
$npm install -g bower
//install mean
$npm install -g mean-cli
$cd project && npm install
$bower install
$gulp
//app start
$node server
2016년 1월 15일 금요일
Node.js install version 4.x and 5.x
Node.js download Link : https://nodejs.org/en/download/package-manager/
Using package manager (My case is Ubuntu, apt-get)
Nodejs.org site page below.
Debian and Ubuntu based Linux distributions
Also including:
Linux Mint, Linux Mint Debian Edition (LMDE), elementaryOS and others.
Node.js is available from the NodeSource Debian and Ubuntu binary distributions repository (formerly Chris Lea'sLaunchpad PPA).
Support for this repository, along with its scripts, can be found on GitHub at nodesource/distributions.
NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
Alternatively, for Node.js v5:
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
sudo apt-get install -y nodejs
Optional: install build tools
To compile and install native addons from npm you may also need to install build tools:
sudo apt-get install -y build-essential
2016년 1월 14일 목요일
Node.js + Express4 use forever + nodemon
Use command on project directory.
$ forever start -c nodemon ./bin/www
2016년 1월 13일 수요일
Node.js v5.0 install on ubuntu
If you want to install Node.js version 5.0
using NVM
GitHub : https://github.com/creationix/nvm
1. install script (file : nvm.sh)
- using curl
$curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.30.1/install.sh | bash
- using wget$wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.30.1/install.sh | bash
2. manual install$git clone https://github.com/creationix/nvm.git ~/.nvm && cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`
# If console shows no command 'nvm' found,
add to ~/.bashrc OR ~/.profile OR ~/.zshrc append this code.
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
3. install Node.js$nvm install 5.0
4. use Node.js - use 5.0 version$nvm use 5.0
And now just use it, Node.js v5.02015년 9월 6일 일요일
node.js 사용시 npm install -g 한 프로그램들이 실행되지 않는 경우
$sudo ln -s /usr/bin/nodejs /usr/local/bin/node
위의 명령어로 디렉토리를 복사해줘야 실행이 된다.
forever, pm2 를 사용하려 했는데 명령어는 있는 것 같은데
실행이 안되서 찾아봤더니 폴더 경로가 안맞는거라서
디렉토리만 연결해주면 실행이 잘된다.
위의 명령어로 디렉토리를 복사해줘야 실행이 된다.
forever, pm2 를 사용하려 했는데 명령어는 있는 것 같은데
실행이 안되서 찾아봤더니 폴더 경로가 안맞는거라서
디렉토리만 연결해주면 실행이 잘된다.
2015년 3월 4일 수요일
linux reserve command for reload nodejs
echo "kill 8009 && nohup node app 2" | at 01:30 2015-03-04
kill [process id] && nohup node app
and
use at command
(this command serviced by atd)
리눅스에서 예약작업을 위해 at 명령어를 쓰는데
atd(at 데몬)이 켜져있어야 하며
(안켜져 있으면 service std start 해주면 된다)
테스트 명령어는
echo "echo hello > /home/test/test.txt" | at 1:30 2015-03-04
위의 명령어로 테스트 후에
node app을 재 실행하는 명령어로 다시 바꿔서
우선 node app pid를 알아내고 그후에 작업시작
echo "kill 8009 && nohup node app 2" | at 01:30 2015-03-04
했더니 잘 된다.
2014년 10월 21일 화요일
node.js server cluster test
Node.js Server Cluster test Benchmark using AB(Apache Banchmark)
server code(no cluster)var http = require("http"); http.createServer(function(request, response) { var s = 64*1024; var buf = new Buffer(s); for(var i=0;i<buf.length;i++){ buf[i]=100; } //console.log("Request for: " + request.url); response.writeHead(200); response.end(buf); }).listen(3000);output
==========================================
==========================================
ab result
Server Software: | |||
---|---|---|---|
Server Hostname: | localhost | ||
Server Port: | 3000 | ||
Document Path: | / | ||
Document Length: | 65536 bytes | ||
Concurrency Level: | 200 | ||
Time taken for tests: | 17.481 seconds | ||
Complete requests: | 10000 | ||
Failed requests: | 0 | ||
Total transferred: | 656110000 bytes | ||
HTML transferred: | 655360000 bytes | ||
Requests per second: | 572058.72 | ||
Transfer rate: | 37533344.59 kb/s received | ||
Connnection Times (ms) | |||
min | avg | max | |
Connect: | 0 | 0 | 15 |
Processing: | 40 | 346 | 826 |
Total: | 40 | 346 | 841 |
server code(cluster)
var cluster = require("cluster"); var http = require("http"); var numCPUs = require("os").cpus().length; if (cluster.isMaster) { for (var i = 0; i < numCPUs; i++) { cluster.fork(); } } else { var s = 64*1024; var buf = new Buffer(s); for(var i=0;i<buf.length;i++){ buf[i]=100; } http.createServer(function(request, response) { //console.log("Request for: " + request.url); response.writeHead(200); response.end(buf); }).listen(3000); }
output
======================================
======================================
ab result
Server Software: | |||
---|---|---|---|
Server Hostname: | localhost | ||
Server Port: | 3000 | ||
Document Path: | / | ||
Document Length: | 65536 bytes | ||
Concurrency Level: | 200 | ||
Time taken for tests: | 19.403 seconds | ||
Complete requests: | 10000 | ||
Failed requests: | 0 | ||
Total transferred: | 656110000 bytes | ||
HTML transferred: | 655360000 bytes | ||
Requests per second: | 515385.73 | ||
Transfer rate: | 33814973.33 kb/s received | ||
Connnection Times (ms) | |||
min | avg | max | |
Connect: | 0 | 0 | 13 |
Processing: | 70 | 385 | 809 |
Total: | 70 | 385 | 822 |
피드 구독하기:
글 (Atom)
JIRA Plugin - ScriptRunner 소개 #2
관련 글 소개 #1: https://pineoc.blogspot.com/2019/03/scriptrunner-1.html ScriptRunner 소개 #2 지난 글에서는 Behaviours를 보았고 다음 내용인 콘솔, 리스너 등을 ...
-
에반젤리스트(Evangelist)란 무엇일까요? 단어 그대로 말한다면 '전도사'의 의미를 가지고 있습니다. 그리고 제가 공부하는 IT업계에서도 이 에반젤리스트가 있지요. 이분들이 하는 일은 쉽게 말해서 기술에 대해 전파하고 알리...
-
Nginx 를 이번에 사용하게 되었는데요. Nginx를 이용해서 폴더에 있는 파일을 받을 수 있게 하려합니다. mac OS에서 테스트할때의 nginx 의 nginx.conf 파일은 /usr/local/etc/nginx/nginx.conf 경...