nodeJs설치
- 아래 공식 홈페이지에서 node.js 설치파일 다운로드
Node.js — 어디서든 JavaScript를 실행하세요
Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.
nodejs.org
- 설치 완료 후 cmd를 통해 정상적으로 설치되었는지 확인
npm --version
node --version
Visual Studio Code
- 개발툴은 visual studio code 를 사용함. 아래 홈페이지에서 다운로드
- https://code.visualstudio.com/
Visual Studio Code - Code Editing. Redefined
Visual Studio Code redefines AI-powered coding with GitHub Copilot for building and debugging modern web and cloud applications. Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows.
code.visualstudio.com
Pagage.json 생성
- npm init 명령어를 통해 package.json 생성
- package.json은 maven과 비슷한 역할을 함.
- 아래 에러가 발생하는경우 해당 경로(C:\~~\npm.ps1)의 ps1확장자 삭제하여 해결
npm : 이 시스템에서 스크립트를 실행할 수 없으므로 C:\~~\npm.ps1 파일을 로드할 수 없습니다.
실행
- package.json 에서 main으로 작성한 js파일을 생성하고 테스트할 코드를 작성
// package.json
{
// ...
"main": "index.js",
// ...
}
// index.js
console.log("test");
- Run and Debug 탭에서 create a lunch.json file. 을 클릭 후 Node.js 선택
- 생성된 실행버튼을 클릭해보면 정상적으로 테스트 코드가 실행되는것을 확인 할 수 있다.
'Script > Node.js' 카테고리의 다른 글
[Node.js] Node.js Restful API Example (0) | 2025.01.13 |
---|---|
[Node.js] Node.js 유용한 패키지들 (0) | 2025.01.13 |
[Node.js] Node.js EJS 템플릿 적용 (0) | 2025.01.06 |
[Node.js] Node.js로 간단한 Todo리스트 API 만들기 (0) | 2025.01.03 |
[Node.js] 간단한 Node.js API Server 셋팅하기 (0) | 2025.01.03 |