NodeJs

ESLint Auto Fix via CLI

最近有時間執返好D code 開始set 返好D ESLint 發現 update 左 eslint config後.. 有很多files 要fix 如果有command / function 可以一次過scan and fix 曬便好 解決方法 我們只需要在 CLI 上執行這個 eslint command 便可 npx eslint --fix …

NextJs - How to change port

最近想 Upgrade 現有的 NextJs Project 所以諗住用 npx create-next-app@latest 來建立一個新的 project 來做 migration 問題出現了… NextJs 的 default port 是 3000 那麼怎樣可以更改其中一個project 的 starting port 呢? 解決方法 我們只需要更新 …

NodeJs - SyntaxError Cannot use import statement outside a module

嘗試起個新既 NodeJs project 用 import rather than require 時出現以下 Exception.. SyntaxError: Cannot use import statement outside a module 解決方法: 原來只要係 package.json 上 加返以下 property 便可.. "type": …

ReferenceError: regeneratorRuntime is not defined jest nodejs

今日係 NodeJs 上用 Jest 寫 Unit Test 時出現了以下錯誤信息 ReferenceError: regeneratorRuntime is not defined ReferenceError: regeneratorRuntime is not defined 解決方法: 只要在 NodeJs Project 上安裝 …

How to get distinct values from an array of objects in JavaScript

今日有個 task 其中一個地方要在 Array of Json object 中 Distinct 一個 property const data = [ { id: 1, category: 'fruit', name: 'Apple', }, { id: 2, category: 'fruit', name: 'Banana', }, { id: 3, …

Firebase ReactJs routing issue - Page not found

使用 firebase hosting 來 host reactjs 既時候 出現了以下問題 當我直接在 browser 輸入 ReactJs 的 route 既時候 出現了 Page Not Found This file does not exist and there was no index.html found in the current …

RaspberryPi install NodeJs 6.x / 7.x - 如何在RaspberryPi 安裝 NodeJs

今日嘗試在RaspberryPi上安裝Johnny-Five /CylonJs 時出現NodeJs 的版本問題 但是執行 sudo apt-get install node 他說 NodeJs已經安裝了 做了一會 research 之後 發現我們可以使用以下方法來更新這個NodeJs的 解決方法 我𠍒可以在Terminal 上執行以下command …