node -v
npm -v
npm init -y
npm install moment
let moment = require('moment');
console.log(`moment : ${moment()}`)
console.log(`포맷 지정 : ${moment().format("YYYY-MM-DD")}`)
console.log(`연 : ${moment().year()}`)
console.log(`월 : ${moment().month()}`) // 0〜11의 값
console.log(`일 : ${moment().date()}`)
console.log(`요일 : ${moment().day()}`)
console.log(`시 : ${moment().hours()}`)
console.log(`분 : ${moment().minutes()}`)
console.log(`초 : ${moment().seconds()}`)
우리도 패키지를 만들어 배포할 수 있습니다.
우리가 package를 설치하면 아래와 같이 package.json이 자동적으로 입력되게 되는데요. 이는 추후 정확한 package를 설치해서 소스코드에 오류가 없게 함입니다.
{
  "name": "expressProject",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {
    "test": "echo \\"Error: no test specified\\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "express": "^4.17.1",
    "express-validator": "^6.13.0"
  },
  "devDependencies": {
    "nodemon": "^2.0.14"
  }
}
명세입니다.
{
  "name": "프로젝트 이름",
  "version": "프로젝트 버전",
  "description": "프로젝트 설명",
  "main": "app.js(진입점)",
  "scripts": {
    // 프로젝트에서 자주사용하는 명령어(npm run test, npm run start, npm start)
    "hello": "echo hello world!",
    "start": "node index.js",
    "test": "echo \\"Error: no test specified\\" && exit 1"
  },
  "keywords": [프로젝트참조키워드],
  "author": "제작자 이름",
  "license": "패키지 라이센스",
  "dependencies": {
    // 프로젝트에서 사용하는 모듈
    "express": "^4.17.1",
    "express-validator": "^6.13.0"
  },
    // 프로젝트에서 개발 시에만 의존하는 모듈
  "devDependencies": {
    "nodemon": "^2.0.14"
  }
}
패키지 배포 및 삭제에 좋은 글이 있어 소개해드립니다.
Version은 아래와 같이 표기됩니다. 위에 버전에 대입해서 보세요.
1.2.3
// major.minor.patch
// 메이저가 업데이트 되면 기존 버전과 호완이 안될 확율이 매우 높습니다! 업데이트 주의해주세요.
// ^(캐럿) : minor 버전까지 설치 또는 업데이트
// ~(틸드) : patch 버전까지 설치 또는 업데이트
// <, <=, >, >=, =
Version에 대한 좋은 글입니다.
npm version에 대한 공식 사이트에서 version 관련 사항을 설명해드리겠습니다.
사용할 수 있는 semver 정리해놓은 사이트에요.