Node.js tips and tricks: Difference between revisions

From HPCWIKI
Jump to navigation Jump to search
(Added Knowledge Graph section)
(원본 2026-04-14 개정본(revid 2310) 복원 — 자동화 수정분 되돌림)
Tag: Manual revert
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Status
=== Update nodejs package.json ===
|status=Draft
|owner=Knowledge Agent
|last_update=2026-07-16
|review=Pending
}}
 
{{TOC}}
 
== Overview ==
 
Node.js tips and tricks에 대한 기술 문서입니다.
 
=== Summary ===
 
* 무엇인가? - Node.js tips and tricks
* 왜 필요한가? - HPC 및 서버 환경에서 필수 개념
* 언제 사용하는가? - 서버 구성, 성능 튜닝, 문제 해결 시
 
---
 
== Purpose ==
 
이 문서가 존재하는 이유
 
* Goal: Node.js tips and tricks에 대한 기술 정보 제공
* Scope: Node.js tips and tricks의 개념, 사용법, 설정
* Non-goals: 다른 주제로의 확장
 
---
 
== Key Concepts ==
 
{| class="wikitable"
! Concept
! Description
! Related
|-
| Node.js tips and tricks
| HPC/서버 환경에서 중요한 기술 개념
| [[Linux]], [[Server]]
|}
 
---
 
== Detailed Explanation ==
 
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
# Install npm-check-updates globally
# Install npm-check-updates globally
$ npm i -g npm-check-updates
$ npm i -g npm-check-updates
# Inside of nodejs project folder where package.json is located
# Inside of nodejs project folder where package.json is located
$ ncu -u
$ ncu -u
Line 58: Line 13:
  cookie-parser                  ^1.4.4  →    ^1.4.7
  cookie-parser                  ^1.4.4  →    ^1.4.7
....
....
# Run npm install to install new versions.
# Run npm install to install new versions.
$ npm install
$ npm install
</syntaxhighlight>
</syntaxhighlight>
== Install NVM ==
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
source ~/.bashrc
source ~/.bashrc
# List up node version
# List up node version
nvm list-remote
nvm list-remote


---
# Install specific version
nvm install 18.0.0


== Best Practices ==
# List of installed versions
nvm ls


* 최신 버전 사용 권장
# Change version
* 공식 문서 참고
nvm use 16.15.0
* 테스트 환경에서 먼저 검증


---
# Update npm
npm install -g npm@latest


== References ==
</syntaxhighlight>


* [https://wiki.hpcmate.com Node.js tips and tricks]
== Install latest Node.js<ref>https://deb.nodesource.com/</ref> ==
<syntaxhighlight lang="bash">
#Install Node.js 20.x LTS
$curl -fsSL https://deb.nodesource.com/setup_20.x | sudo bash -
$sudo apt-get install -y nodejs


---
</syntaxhighlight>


== Related Pages ==
== Change node version ==
<syntaxhighlight lang="bash">
# Get available version list using nvm
$ nvm ls
        v4.9.1
        v6.17.1
        v8.8.1
        v8.9.4
        v8.17.0
      v10.24.1
->    v14.15.1
      v16.20.0
      v18.16.0
        system
default -> v14.15.1


* [[Linux]]
# change version v18 temporary and check the changing version
* [[Server]]
$ nvm use v18.16.0
* [[Hardware]]
$ nvm ls
* [[Network]]
        v4.9.1
        v6.17.1
        v8.8.1
        v8.9.4
        v8.17.0
      v10.24.1
      v14.15.1
      v16.20.0
->    v18.16.0
        system
default -> v14.15.1            << default version will not be changed


---
# change default version v18 sytemwide
$ nvm alias default v18
default -> v18 (-> v18.16.0)


[[Category:Server]]
$ nvm ls
== Knowledge Graph ==
        v4.9.1
        v6.17.1
        v8.8.1
        v8.9.4
        v8.17.0
      v10.24.1
      v14.15.1
      v16.20.0
->    v18.16.0
        system
default -> v18 (-> v18.16.0)    << default version has been changed
node -> stable (-> v18.16.0) (default)
stable -> 18.16 (-> v18.16.0) (default)


Related
# Install new version of node
$ nvm install <version you want to>
</syntaxhighlight>


→ [[Linux]]
== References ==
→ [[Server]]
<references />
→ [[Hardware]]
→ [[Network]]
 
[[Category:Reference]]

Latest revision as of 13:59, 7 November 2026

Update nodejs package.json

# Install npm-check-updates globally
$ npm i -g npm-check-updates

# Inside of nodejs project folder where package.json is located
$ ncu -u
Upgrading /opt/imp/home/prj/package.json
[====================] 39/39 100%
...
 async                           ^2.6.3  →    ^3.2.6
 cheerio                    ^1.0.0-rc.2  →    ^1.0.0
 cookie-parser                   ^1.4.4  →    ^1.4.7
....

# Run npm install to install new versions.
$ npm install

Install NVM

curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
source ~/.bashrc

# List up node version
nvm list-remote

# Install specific version
nvm install 18.0.0

# List of installed versions
nvm ls

# Change version
nvm use 16.15.0

# Update npm 
npm install -g npm@latest

Install latest Node.js[1]

#Install Node.js 20.x LTS
$curl -fsSL https://deb.nodesource.com/setup_20.x | sudo bash - 
$sudo apt-get install -y nodejs

Change node version

# Get available version list using nvm
$ nvm ls
         v4.9.1
        v6.17.1
         v8.8.1
         v8.9.4
        v8.17.0
       v10.24.1
->     v14.15.1
       v16.20.0
       v18.16.0
         system
default -> v14.15.1

# change version v18 temporary and check the changing version
$ nvm use v18.16.0
$ nvm ls
         v4.9.1
        v6.17.1
         v8.8.1
         v8.9.4
        v8.17.0
       v10.24.1
       v14.15.1
       v16.20.0
->     v18.16.0
         system
default -> v14.15.1             << default version will not be changed

# change default version v18 sytemwide
$ nvm alias default v18
default -> v18 (-> v18.16.0)

$ nvm ls
         v4.9.1
        v6.17.1
         v8.8.1
         v8.9.4
        v8.17.0
       v10.24.1
       v14.15.1
       v16.20.0
->     v18.16.0
         system
default -> v18 (-> v18.16.0)    << default version has been changed
node -> stable (-> v18.16.0) (default)
stable -> 18.16 (-> v18.16.0) (default)

# Install new version of node
$ nvm install <version you want to>

References