Wed, Oct 20, 21, install nodejs versions and shorthand cli options

Thi

  • /NPM-install
  • Install NodeJS & NPM

    Install multiple versions

    First, need to install nvm. Run the line of curl and then run/add-to-bash the line of export.

    ::: warning Below commands are mostly for Linux/MacOS users. :::

    ::: col-2-equal

    # FIRST INSTALL: the most recent lts release
    nvm install --lts
    
    # install a specific version
    nvm install 12.13.0
    
    # install latest version
    nvm install node
    
    # list all installed versions
    nvm ls
    
    # set default version of node
    nvm alias default 12.13.0
    
    # full list of available versions
    # be careful, it's too long!!!
    nvm ls-remote
    
    # switch between versions
    nvm use 12.13.0
    # or (more quickly)
    nvm use v15
    
    # uninstall some version
    nvm uninstall 12.13.0
    

    :::

    Single version

    ๐Ÿ‘‰ Install NodeJS and NPM: Windows & MacOS, Linux.

    ::: col-2-equal

    # UPDATE npm
    npm cache clean -f # clear the cache first
    sudo npm install -g npm
    
    # UPDATE node
    sudo npm install -g n
    sudo n stable
    # refresh the shell
    source ~/.zshrc # if using zsh
    source ~/.bashrc # is using bash
    
    # Check version
    npm -v
    node -v
    

    :::

    Shorthand CLI options

    • i: install
    • -D: --save-dev (devDependencies)
    • -P: --save-prod (default), --save
    • -g: --global
    • -f: --force
    • ls: list

    Install package

    ๐Ÿ‘‰ Official documentation.

    npm install package_name # if it's in package.json, the indicated version will be installed
                             # otherwise, the newsest version will be installed
    npm install --global package_name # global package
    
    # install all package in package.json
    npm install
    
    # install + save to package.json
    npm install --save package_name # save to package.json
    npm install --save-dev package_name # save to package.json, in devDependencies
    npm install --no-save package_name # don't save
    
    # install with version
    npm install express@4.16.1
    
    # install a local package
    npm install /path/to/package
    
    # from github repository
    npm i git+https://github.com/abc/xyz.git # https
    # or
    npm i git+ssh://git@github.com/abc/xyz.git # ssh
    
    # list all installed packages (current project only)
    ls node_modules
    
    # list all local (installed) packages
    npm list # -g for globel # or use "ls"
    npm list --depth=0 # without dependencies
    
    # Check the current version of a (installed) package
    npm list package_name # with "-g" for global
    
    # Check the latest (not current) version of a package
    npm view package_name version
    
    # Set python2 by default when installing npm packages
    npm config set python python2
    

    Update package

    ::: col-2-equal

    # which global packages need to be updated?
    npm outdated -g --depth=0
    
    # update all global packages
    npm update -g
    
    # update a package
    npm update package_name # -g for global
    

    :::

    Remove package

    npm uninstall package
    

    Run scritps

    # Install first
    npm i --save npm-run-all
    

    ::: col-2-equal

    // Run sequentially,
    // package.json
    "scripts": {
    	"build": "run-s prod:*", // "run-s" = "npm-run-all -s"
    	"prod:eleventy": "eleventy",
    	"prod:parcel": "parcel build ./ -o ./",
    }
    
    // Run parallely,
    // package.json
    "scripts": {
    	"start": "npm-run-all --parallel dev:*",
    	"dev:eleventy": "eleventy --serve",
    	"dev:parcel": "parcel watch ./ -o ./",
    }
    

    :::

    The following wiki, pages and posts are tagged with

    TitleTypeExcerpt
    2021-10-01-wiki-magnific-popup.md post ์ง€ํ‚ฌ ๋ธ”๋กœ๊ทธ์— ์ด๋ฏธ์ง€ ํ™•๋Œ€ ๊ธฐ๋Šฅ ์ถ”๊ฐ€ํ•˜๊ธฐ
    Jekyll + liquid post Monday-jekyll-liquid, jekyll install on mac and ubuntu using docker
    css tips for web development post Tue, Oct 19, 21, tools, fonts cascading and selectors
    auto focus when page loads post Tue, Oct 19, 21, auto-focus media-query google-font
    keycode css trics for search focus post Wednesday-keycode, how to find keycode for the kb input keys
    using css and jquery to switch between themes post Wed, Oct 20, 21, toggle icon, flash loading fix, DOM loaded before show content
    tools for webdev post Sat, Oct 23, 21, tools for webdev frameworks, drawing, visualization text-editor
    Complete guide to django rest framework and vue js post Wed, Nov 10, 21, Build professional REST APIs and spa with django vue
    mvc-mvt definition post Fri, Dec 24, 21, difference between mvc and mvt
    ๋กœ์ปฌ ๊ตฌ๊ธ€ Apps Script ๊ฐœ๋ฐœ post ํŠœํ† ๋ฆฌ์–ผ ๋”ฐ๋ผํ•˜๊ธฐ
    ๊ฐœ๋ฐœ์ž์˜ ๊ธ€์“ฐ๊ธฐ post ๊ฐœ๋ฐœ์ž ๊ธ€์“ฐ๊ธฐ์˜ 3์›์น™ : ์ •ํ™•์„ฑ, ๊ฐ„๊ฒฐ์„ฑ, ๊ฐ€๋…์„ฑ, ๋ณ€์ˆ˜ ๋„ค์ด๋ฐ๋ถ€ํ„ฐ ๋ฆด๋ฆฌ์Šค๋…ธํŠธ...
    ํŒŒ์ด์ฌ ์ฝ”๋”ฉ์˜ ๊ธฐ์ˆ  2ํŒ post ๋˜‘๋˜‘ํ•˜๊ฒŒ ์ฝ”๋”ฉํ•˜๋Š” ๋ฒ•
    ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋Š” ์™œ ๊ทธ ๋ชจ์–‘์ผ๊นŒ? page ๋”๊ธ€๋ผ์Šค ํฌ๋ฝํฌ๋“œ๊ฐ€ ์•Œ๋ ค์ฃผ๋Š”
    javascript for impatient page Exploit the power of modern javascript and avoid the pitfalls
    Practical Vim post ์†์ด ๋จผ์ € ๋ฐ˜์‘ํ•˜๋Š”
    ๋ฆฌํŒฉํ† ๋ง 2ํŒ page ์ฝ”๋“œ ๊ตฌ์กฐ๋ฅผ ์ฒด๊ณ„์ ์œผ๋กœ ๊ฐœ์„ ํ•˜์—ฌ ํšจ์œจ์ ์ธ ๋ฆฌํŒฉํ„ฐ๋ง ๊ตฌํ˜„ํ•˜๊ธฐ
    ํ•œ ๊ถŒ์œผ๋กœ ๋๋‚ด๋Š” ์ •๊ทœํ‘œํ˜„์‹ page ์—ฌ๋Ÿ ๊ฐ€์ง€ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด๋ณ„ ์™„๋ฒฝ ํ•ด์„ค
    ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ์ฝ”๋”ฉ์˜ ๊ธฐ์ˆ  page ๋˜‘๋˜‘ํ•˜๊ฒŒ ์ฝ”๋”ฉํ•˜๋Š” ๋ฒ•
    typescript๋กœ ๊ฐœ๋ฐœ์‹œ ํŒŒ์ผ ์ˆœ์„œ ๋ฌธ์ œ post typescript hoisting filepushorder
    css-meaning.md post toc์˜ css๋ฅผ ์กฐ์ •ํ•˜๋‹ค๊ฐ€ ์šฐ์—ฐํžˆ ๊นจ๋‹ซ๊ฒŒ ๋œ CSS ์–ด์›์˜ ์˜๋ฏธ
    Djangovue a fastrack to success page summary.
    refactoring.md post toc์˜ css๋ฅผ ์กฐ์ •ํ•˜๋‹ค๊ฐ€ ์šฐ์—ฐํžˆ ๊นจ๋‹ซ๊ฒŒ ๋œ CSS ์–ด์›์˜ ์˜๋ฏธJavascript ์—์„œ ์ถœ๋ ฅ๋œ html string์„ ๋ธŒ๋ผ์šฐ์ €๋กœ ํ™•์ธํ•˜๊ธฐ
    wiki-favicon.md post favicon ์ถ”๊ฐ€ ๋ฐฉ๋ฒ•, ๊ด€๋ จ ๋งํฌ
    wiki-innerhtml.md post View ์—์„œ ๊ฐ€์ ธ์˜จ data ๋ฅผ ํ‘œ๊ธฐํ•˜๋Š” ๊ณผ์ •์—์„œ ๋ฌธ๋“ value, textContent, innerHTML, innerText์˜ ์ฐจ์ด
    wiki-toc2side.md post CSS๋ฐ SCSS์— ๋Œ€ํ•œ ์ •๋ฆฌ