'Programming/node.js'에 해당되는 글 142건

  1. 2018.09.06 node.js exec()
  2. 2018.09.05 node.js / express/ pug(jade) 문법
  3. 2018.09.05 npm package.json
  4. 2018.09.04 nodaemon
  5. 2018.09.04 node.js + AJAX 테스트
  6. 2018.09.04 node.js CORS
  7. 2018.09.03 node.js와 웹소켓
  8. 2018.08.29 node.js 와 v8
  9. 2018.08.29 node.js odroid
  10. 2018.08.17 node.js refresh
Programming/node.js2018. 9. 6. 18:45

js 라고는 해도 서버사이드로 확장되면서 서버에서는 당연히(?) 있어야 할 exec()가 추가되었다.

아무튼 exec()로 나오는 결과를 받아서 먼가 처리하는 것 까지는 해봐야 할 듯..


[링크 : https://blog.outsider.ne.kr/551]

[링크 : https://mylko72.gitbooks.io/node-js/content/chapter9/chapter9_2.html]

[링크 : https://nodejs.org/api/child_process.html]


+

2018.09.07

var exec = require('child_process').exec,

child;


child = exec("dir", function(error, stdout, stderr)

{

console.log(stdout);

if(error !== null)

{

console.log(error);

}

});


D:\node_test>node test.js

 D ����̺��� ����: �� ����

 ���� �Ϸ� ��ȣ: CCEE-4FEA


 D:\node_test ���͸�


2018-09-07  ���� 10:38    <DIR>          .

2018-09-07  ���� 10:38    <DIR>          ..

2018-09-07  ���� 10:35               195 test.js

2018-09-07  ���� 10:38                 0 test.txt

2018-09-07  ���� 10:38                 0 �� �ؽ�Ʈ ����.txt

               3�� ����                 195 ����Ʈ

               2�� ���͸�  916,882,796,544 ����Ʈ ���� 


윈도우에서 euc-kr로 받아서 그런가.. 옵션에 euc-kr encoding 해주어도 깨지는건 여전하네..

어짜피 영어로 주고 받을테니 일단 패스~ ㅠㅠ

[링크 : https://junistory.blogspot.com/2017/08/blog-post_24.html]


+

파일이 ANSI라서 보는데 이런식으로 인코딩 바꾸니 

 hild = exec("type test.txt", {encoding: 'ansi'}, function(error, stdout, stderr)


배쨴다 ㅠㅠ

D:\node_test>node test.js

<Buffer 7b 0d 0a 20 20 20 20 22 6e 61 6d 65 22 3a 20 22 bd c4 bb a7 22 2c 0d 0a 20 20 20 20 22 66 61 6d 69 6c 79 22 3a 20 22 c0 a3 bd c3 c4 da b1 e2 22 2c 0d ... > 


'Programming > node.js' 카테고리의 다른 글

node.js exec와 JSON.parse()  (0) 2018.09.07
node.js express template  (0) 2018.09.06
node.js / express/ pug(jade) 문법  (0) 2018.09.05
npm package.json  (0) 2018.09.05
nodaemon  (0) 2018.09.04
Posted by 구차니
Programming/node.js2018. 9. 5. 12:50

node.js 다루는데 템플릿으로 받은게 pug로 된거라 문법 찾는중

기본적으로(?) 클래스만 선언하면 무조건 div로 생성되니 조금은 고민하고 써야 할 듯


[링크 : http://jeong-pro.tistory.com/65]

[링크 : https://pugjs.org/]

'Programming > node.js' 카테고리의 다른 글

node.js express template  (0) 2018.09.06
node.js exec()  (0) 2018.09.06
npm package.json  (0) 2018.09.05
nodaemon  (0) 2018.09.04
node.js + AJAX 테스트  (0) 2018.09.04
Posted by 구차니
Programming/node.js2018. 9. 5. 11:26

npm install [package name]으로는 개별설치는 하는 반면

package.json 이라는 파일이 있으면

npm install 으로 의존성을 한번에 설치한다.

[링크 : https://blog.outsider.ne.kr/665]


npm init 으로 package.json을 생성할 수 있다.

[링크 : https://blog.outsider.ne.kr/674]


'Programming > node.js' 카테고리의 다른 글

node.js exec()  (0) 2018.09.06
node.js / express/ pug(jade) 문법  (0) 2018.09.05
nodaemon  (0) 2018.09.04
node.js + AJAX 테스트  (0) 2018.09.04
node.js CORS  (0) 2018.09.04
Posted by 구차니
Programming/node.js2018. 9. 4. 19:34

angular 처럼 서버 소스 수정하면 재시작 하는 서비스


[링크 : https://nodemon.io/]

[링크 : https://github.com/remy/nodemon]



+

2018.09.05


실행방법이 먼가 까다로워 보여서 고민하다가 찾아 보니

조금 길지만 직관적인(?) 방법이 존재해서 일단 실행


This will be simple command for this

nodemon --exec npm start 

[링크 : https://stackoverflow.com/questions/33879896/how-to-execute-start-script-with-nodemon]

[링크 : https://www.npmjs.com/package/nodemon]


그나저나 다시 보니

no demon 이라기 보다는 node mon(itor)였네?

아이콘에 악마가 있어서 푸흡 했는데 ㄷㄷ


아무튼 js 파일들을 수정하니 자동으로 이런 메시지가 뜨면서 서버를 재기동 시킨다.

(node.js 소스는 건드리지 않고 모니터 통해서 실행시키면 되니 개꿀)


'Programming > node.js' 카테고리의 다른 글

node.js / express/ pug(jade) 문법  (0) 2018.09.05
npm package.json  (0) 2018.09.05
node.js + AJAX 테스트  (0) 2018.09.04
node.js CORS  (0) 2018.09.04
node.js와 웹소켓  (0) 2018.09.03
Posted by 구차니
Programming/node.js2018. 9. 4. 11:27

해보니 1초 정도 늦게 나오는거 봐서는 cpu사용율 샘플링 시간을 1초 정도로 잡고 있는 것으로 보인다.


var os = require('os-utils');


os.cpuUsage(function(v){

    console.log( 'CPU Usage (%): ' + v );

}); 


[링크 : https://github.com/oscmejia/os-utils]

[링크 : https://stackoverflow.com/questions/36816181/get-view-memory-cpu-usage-via-nodejs]



<script type="text/javascript">

$(document).ready(function()

{

var sys = {};

$.ajax(

{

url:'http://localhost:3000/sys',

type:'get',

success:function(data)

{

$('#result').text(data.mem);

}

})

});

</script>

<div id="result">blah blah</div>



머. 이로서(?) ajax + node.js 까지 끝(?!)


[링크 : https://opentutorials.org/course/1375/6851]

'Programming > node.js' 카테고리의 다른 글

npm package.json  (0) 2018.09.05
nodaemon  (0) 2018.09.04
node.js CORS  (0) 2018.09.04
node.js와 웹소켓  (0) 2018.09.03
node.js 와 v8  (0) 2018.08.29
Posted by 구차니
Programming/node.js2018. 9. 4. 11:21

Cross Origin Resource Sharing

다른 도메인의 자원을 공유하는 것으로


RESTful API의 사용으로 웹서버와 REST 서버가 분리됨으로 인해

웹 브라우저에서 크로스 사이트에 대한 보안 정책에 위배되어 접근이 불가능한 것을 우회해주는 설정

(생각해보면 iframe에서 다른 도메인꺼 넣으면 안되던것의 연장선?)


node.js에서 헤더 설정

[링크 : http://guswnsxodlf.github.io/enable-CORS-on-express]


CORS 크롬 플러그인

[링크 : https://chrome.google.com/webstore/detail/allow-control-allow-origi/n.../related?hl=ko]

'Programming > node.js' 카테고리의 다른 글

nodaemon  (0) 2018.09.04
node.js + AJAX 테스트  (0) 2018.09.04
node.js와 웹소켓  (0) 2018.09.03
node.js 와 v8  (0) 2018.08.29
node.js odroid  (0) 2018.08.29
Posted by 구차니
Programming/node.js2018. 9. 3. 17:29

polling 보다는 interrupt가 낫듯(?)

ajax 단기간 빠른 polling 대신 웹소켓 검색



[링크 : https://poiemaweb.com/nodejs-socketio] node.js + socket.io

[링크 : https://www.a-mean-blog.com/ko/blog/단편강좌/_/Node-JS-Socket-io-채팅사이트-만들기]


[링크 : http://html5korea.com/웹소켓websocket-시작하기강의번역/] php 기반

'Programming > node.js' 카테고리의 다른 글

node.js + AJAX 테스트  (0) 2018.09.04
node.js CORS  (0) 2018.09.04
node.js 와 v8  (0) 2018.08.29
node.js odroid  (0) 2018.08.29
node.js refresh  (0) 2018.08.17
Posted by 구차니
Programming/node.js2018. 8. 29. 19:12

v8 javascript 엔진을 기반으로 초반에는 node.js를 구현한듯?

근데 여전히.. v8 snapshot 기능은 못 찾음(arm에서 작동 안되는 이유가 얘라고..)


[링크 : https://blog.ghaiklor.com/how-nodejs-works-bfe09efc80ca]

[링크 : https://stackoverflow.com/questions/42616120/what-is-the-relationship-between-node-js-and-v8]

'Programming > node.js' 카테고리의 다른 글

node.js CORS  (0) 2018.09.04
node.js와 웹소켓  (0) 2018.09.03
node.js odroid  (0) 2018.08.29
node.js refresh  (0) 2018.08.17
html5 / css3 / jquey ajax / angularJS  (0) 2018.08.08
Posted by 구차니
Programming/node.js2018. 8. 29. 19:06

odroid에서 node.js 하려면

빌드할때 snapshot 기능을 꺼야 한다고 한다.


[링크 : http://awesometic.tistory.com/5]

[링크 : http://lovedove.tistory.com/101]


+

라즈베리에서 node.js 돌리는법

[링크 : https://www.w3schools.com/nodejs/nodejs_raspberrypi.asp]

'Programming > node.js' 카테고리의 다른 글

node.js와 웹소켓  (0) 2018.09.03
node.js 와 v8  (0) 2018.08.29
node.js refresh  (0) 2018.08.17
html5 / css3 / jquey ajax / angularJS  (0) 2018.08.08
typescript - ts  (2) 2018.08.07
Posted by 구차니
Programming/node.js2018. 8. 17. 19:31

node.js에서 소스 건드리면 빌드하고

자동으로 웹 브라우저 리프레시 하는데 그게 신기해서 검색


[링크 : https://www.npmjs.com/package/browser-refresh]

[링크 : http://2ality.com/2012/08/jsreload.html]


+ 2018.09.04

전에 한걸 보니 node.js가 아니라 angular 였고, 

순수 node.js에서는 서버 재시작이나 브라우저 갱신이 지원되지 않는다.


그래도 위의 browser-refresh가 더 인기가 좋은 듯

[링크 : https://www.npmjs.com/package/reload]


+ 2018.09.06

[링크 : https://medium.com/engineering-on-the-incline/reloading-current-route-on-click-angular-5-1a1bfc740ab2]

'Programming > node.js' 카테고리의 다른 글

node.js와 웹소켓  (0) 2018.09.03
node.js 와 v8  (0) 2018.08.29
node.js odroid  (0) 2018.08.29
html5 / css3 / jquey ajax / angularJS  (0) 2018.08.08
typescript - ts  (2) 2018.08.07
Posted by 구차니