# Node js & Pomelo 升版 預計將 pomelo 升至最新版: 2.2.7,同時將環境的 node js / npm / typscript 一並升級 >當前的 node js LTS 為 14.17.3 對應的 ts 版本為 4.3.5 --- ## Node js 升級 首先要安裝 nvm - [`Node Version Manager`](https://github.com/nvm-sh/nvm) 可以透過 terminal 直接安裝 ```shell= curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash // or wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash ``` 安裝完後可以順便 `source ~/.bashrc (or .zshrc)` 查看版號 ```shell= nvm -v ``` ### 安裝新版 node js 列出所有可用版本 ```shell= nvm ls-remote // --lts 可以過濾 LTS 版 ``` 安裝`14.17.3`版 ```shell= nvm install 14.17.3 ``` 查看安裝結果 ```shell= nvm ls ```  `ls` 會列出本機所有安裝的版本 如果 default 不是 14 版的話,可以手動改 ```shell= nvm alias default 14.17.3 ``` 之後要切換其他版本也是用一樣的操作 --- ## Pomelo 升級 node js 升級後記得順便安裝 pomelo 相關套件 ```shell= npm install pomelo pomelo-cli -g ``` 不用指定版號,直接安裝最新版本 >pomelo 已停止維護,最後版號為 `2.2.7` 接著更新專案的套件 package.json ```json= ... "dependencies": { "body-parser": "1.19.0", "crc": "0.2.0", "eslint": "7.31.0", "express": "4.17.1", "mysql": "2.18.1", "pomelo": "2.2.7", "request": "2.79.0", "websocket": "1.0.24", "ws": "7.5.3" }, ... ``` 只留下基本需要的套件,有需要再另外加 `express` 這邊直接升到4版 >4版已經把 `body-parser` 的功能抽離,所以需要另外安裝 >更多[說明](https://expressjs.com/zh-tw/guide/migrating-4.html) 把原先的 `package-lock.json` 以及 `node_modules` 全部刪除,再重新 `npm install` 安裝即可 --- ## 其他相關設定 * `tslint` 目前已經棄用,被 `eslint` 所取代 >[eslint Configuration Files](https://eslint.org/docs/user-guide/configuring/configuration-files#configuration-file-formats) * 新增 `tsconfig.json` for ts compile setting >[tsconfig.json 中文手冊](https://typescript.bootcss.com/tsconfig-json.html)
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up