반응형

Node.js 패키지 생성 및 실행 - Node.js package, npm init, npm run 

 

 

Node.js의 패키지 만들기
 - 폴더 생성
 - 콘솔에서 생성된 폴더로 이동
 - 패키지를 생성하기 위해 npm init 명령어를 실행
 - 폴더에 package.json 파일이 생성됩니다.
D:\_nodejs\nodePjt>
D:\_nodejs\nodePjt>npm init

{
  "name": "test1",
  "version": "1.0.0",
  "description": "test",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "carrotweb",
  "license": "ISC"
}



* 패키지를 설치하는 명령어입니다.
  Express.js 설치하기
  Express.js는 Node.js에서 HTTP와 관련된 컴포넌트를 기반으로 하는 웹 애플리케이션 프레임워크입니다.
  현재 패키지(애플리케이션)에 Express.js를 설치하기 위해 콘솔에서 npm install 명령어를 실행합니다.
  npm install에 옵션으로 --save를 추가하면 자동으로 package.json 파일의 "dependencies"에 "express" 항목이 추가됩니다.

D:\_nodejs\nodePjt>
D:\_nodejs\nodePjt>npm install express --save

{
  "name": "test1",
  "version": "1.0.0",
  "description": "test",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "carrotweb",
  "license": "ISC",
  "dependencies": {
    "express": "^4.17.1" --> 추가
  }
}





 * Node.js의 패키지(애플리케이션) 실행하기
 * Node.js를 종료는 콘솔에서 Ctrl + C를 누르면 됩니다.

D:\_nodejs\nodePjt>
D:\_nodejs\nodePjt>node index.js
Listening...
^C
D:\_nodejs\nodePjt>^C
D:\_nodejs\nodePjt>



=========================================================


접속 : http://localhost:8080/index.html


* npm으로 실행하기 위해 Script 추가하기
* 콘솔에서 npm start를 실행합니다.
  종료하려면 콘솔에서 Ctrl + C를 누르고 "Y"를 입력하고 엔터키를 누르면 됩니다.

D:\_nodejs\nodePjt>npm run start
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.

> nodepjt@1.0.0 start
> node index.js

Listening...



* Express 정적 파일 적용하기
 - index.js를 오픈하여 이미지 파일이나 CSS 파일, JavaScript 파일 등과 같은 정적 파일을 제공하기 위해 
   Express.js의 express.static() 메서드를 추가합니다. 정적 파일들이 들어있는 폴더로 public 폴더를 설정하였습니다.
 - 폴더에 public 폴더를 생성합니다.
 - public 폴더에 index.html 파일을 생성합니다.
 - npm start를 실행합니다.
  

   D:\_nodejs\nodePjt>npm run start



 - 브라우저에서 "http://localhost:8080/index.html"를 입력


반응형
반응형

1. Node.js와 NPM 설치하기 

https://nodejs.org/ko/download/

 

다운로드 | Node.js

Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.

nodejs.org

버전 확인.

 

2. VSCode에서 React 프로젝트 생성

> npm install -g create-react-app

> create-react-app my-app

npm install -g에서 -g옵션은 시스템 디렉터리에 패키지를 설치하는 것을 의미합니다.
-g 옵션이 없다면 module은 현재 디렉터리 내부에 로컬로 설치됩니다.

3. 'my-app' 디렉터리로 이동 후 'npm start' 명령어로 리액트 프로젝트 시작

반응형
반응형

nodeJS의 무중단 관리도구인 Forever 에 대해 알아보겠습니다

node . js 앱을 실행시키거나 비정상 종료되었을 때 재실행을 시켜주는 관리도구입니다

1.forever 설치

npm install forever -g
 

2.forever 시작

forever start [js script]
 

3.forever 종료

forever stop [js script]
 

4.forever 목록

forever list

반응형
반응형
반응형
반응형

[Node.js] npm 소개와 설치


이제 자바스크립트 라이브러리를 찹아보면 왠만하면 node.js에 들어가있다. 

결국 서버사이트로 가는거지. 


내장 http서버 라이브러리를 가지고 있기 때문에 설치만 하면 뚝딱 웹서비스가 돌아간다. 

이걸 서비스에 언제 적용할지가 문제.


npm이란 Node Package Modules의 약자다. Node.js에서 사용가능한 모듈들을 패키지화시켜 모아놓은 것이다.


이것을 설치하고 나면 나중에 업데이트도 쉽고 좋다. 


npm 홈페이지 : https://www.npmjs.org/



물론 개별 설치해서 사용해도 된다. 


Node.js 다운로드 사이트 : http://nodejs.org/download/


Guide :  https://nodejs.org/en/docs/guides/



-----------------------------------------------------------


http://mean.io/


MEAN Stack 을 선호하기도 한다. 


Mongodb + Express + Angularjs + Nodejs




...

반응형
반응형

A-Frame: A framework for the virtual reality web

 

A-Frame

For the core library, check out A-Frame Core.

Building blocks for the VR Web.

  • Virtual Reality: Drop in the library and have a WebVR scene within a few lines of markup.
  • Based on the DOM: Manipulate with JavaScript, use with your favorite libraries and frameworks.
  • Entity-Component System: Use the entity-component system for better composability and flexibility.

Find out more:

 

 

A-Frame is a framework for building things for the virtual reality web. You can use markup to create VR experiences that work across desktop, iPhones, and the Oculus Rift.

a-frame

 

 

 

 

 

.

반응형
반응형

NPM - Node.js를 구성하는 에코시스템

Node Package Manager

 

https://npmjs.org/

 

설치명령 : npm install <pkg>

업데이트 : npm update

삭제       : npm uninstall <pkg>

 

RubyGems - http://rubygems.org

 

Python Package Index - http://pypi.python.org/pypi

 

Node.js manual : http://nodejs.org/api/assert.html

 

NPM List - http://nodejs.wikia.com/wiki/NPM_Modules

 

 

 

 

반응형

+ Recent posts