บทความ

บันทึก

 node -e 'console.log(v8.getHeapStatistics().heap_size_limit)'  node --max-old-space-size=4096 ./bin/www

Nodejs Auth JWT Passport

 Nodejs Auth JWT Passport ref:  Nodejs Auth JWT Passport สร้าง Project express --view=ejs [[projectName]] a b c

Nodejs Basic Web App Project

Nodejs version list ติดตั้ง Nodejs ด้วย NVM (Node Version Manager) สร้าง Folder สำหรับเก็บ Project mkdir [[projectName]] cd [[projectName]] ตั้งค่า Node Version ผ่าน NVM nvm list   >> check node version nvm install [[node version]]   >> ติดตั้ง node version ที่ต้องการ หรือ ใช้ nvm install --lts เพื่อลง node version ล่าสุด nvm use [[node version]]   >> เลือก node version ที่ต้องการใช้ nvm alias [[alias name]] [[node version]]  >> คำสั่งนี้จะเป็นการสร้าง alias ให้กับ node ของเรา เวลาใช้  nvm use [[projectName]] node -v >> check node version npm -v >> check npm version node - > .nvmrc >> เพื่อสร้างไฟล์ .nvmrc ทำให้เรารู้ว่าโปรเจ็คนั้นใช้ node version อะไร เริ่มสร้าง Nodejs Project  โดยใช้ express-generator npm init –y  >> สร้างไฟล์ package.json กรณีไม่ใช้ express-generator npm install express-generator -g >>  ติดตั้ง express-generator (ตั้งแต่ Node.js 8.2.0 มีมาให้แล้วไม่ต้องทำขั้นตอนน...

NVM (Node Version Manager)

 NVM (Node Version Manager): จัดการกับเวอร์ชันของ node ในเครื่องเรา ref: https://github.com/nvm-sh/nvm#nvmrc ref:  https://www.youtube.com/watch?v=sDkOfY7LBLY วิธีติดตั้ง NVM  ติดตั้ง curl sudo apt-get install curl  ติดตั้ง curl curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash คำสั่งพื้นฐานของ nvm nvm ls คำสั่งนี้จะเป็นการแสดงเวอร์ชันของ node.js ที่เราดาวน์โหลดลงมาในเครื่องแล้ว nvm ls-remote คำสั่งนี้เป็นการแสดงเวอร์ชัน node.js ออกมาทางหน้าจอ การแสดงผลทั้งหมดจะนานหน่อย เลขต่าง ๆ ที่แสดงออกมาทางหน้าจอคือเวอร์ชันที่เราสามารถดาวน์โหลดได้โดยใช้คำสั่ง nvm install <version> nvm install <node version>  คำสั่งนี้จะเป็นดาวน์โหลด node และ dependencies ต่าง ๆ จากอินเทอร์เน็ตลงมาสู่เครื่องของเรา โดยเลขเวอร์ชันที่สามารถดาวน์โหลดได้จะมาจากคำสั่ง nvm ls-remote นั่นเอง nvm install v10.15.0 หมายความว่าให้ดาวน์โหลด node js v10.15.0 มาลงเครื่อง ข้อดีของ...

"html-pdf: Failed to load PhantomJS module.

รูปภาพ
วิธีแก้ไขเอาขึ้น server linux แล้ว "error  phantomjs-prebuilt" 1. ลบ lib:  phantomjs-prebuilt ด้วยคำสั่ง   rm -rf node_modules/phantomjs-prebuilt 2.ติดตั้งใหม่ ด้วยคำสั่ง  npm install phantomjs-prebuilt --------------------------------------------- ref: https://github.com/marcbachmann/node-html-pdf/issues/437 ref: https://github.com/marcbachmann/node-html-pdf/issues/212 ref: https://www.javascripttutorial.net/nodejs-tutorial/npm-list/   Copy link ganeshmogare commented on Jun 4, 2018 hi ,i'm trying to use html-pdf module , but it throws "html-pdf: Failed to load PhantomJS module. You have to set the path to the PhantomJS binary using 'options.phantomPath" error , steps i tried to resolve : 1. ...

node js create excel file with xlsx

node js create excel file with xlsx > npm xlsx i ref>>  https://github.com/SheetJS/sheetjs/tree/master/demos/server https://sheetjs.com/demo/manifest.html https://github.com/SheetJS/sheetjs#utility-functions https://github.com/SheetJS/sheetjs#writing-options           var  fileName  =   " 555.xlsx "          var  datas  =   [[ 1 ,   2 ,   3 ],   [ true ,   false ,   null ,   " sheetjs " ],   [ " foo " ,   " bar " ,   new   Date ( " 2014-02-19T14:30Z " ),   " 0.3 " ],   [ " baz " ,   null ,   " qux " ]]          var  wsName  =   " SheetJS "          // console.log(data)          /* generate workbook */          var ...

A way to specify date formating when using XLSX.utils.sheet_to_row_object_array()

Note: these changes are in the repo and will appear in version 0.9.5. If you read in with  cellDates:true , the date-stored-as-number cells will be proper dates. If you set the  dateNF  key of the options object to a number format string, the formatter will use it. Following the example from  my previous comment : > var wb = XLSX . readFile ( ' write.xlsx ' , {cellDates : true }); > wb . Sheets . SheetJS . C3 { t : ' d ' , v : 2014 - 02 - 19T14 : 30 : 00 . 000Z , w : ' 2/19/14 ' } // <-- note: v is a date object > delete wb . Sheets . SheetJS . C3 . w true > XLSX . utils . format_cell ( wb . Sheets . SheetJS . C3 ); ' 2/19/14 ' < -- defaults to the number format code 14 > delete wb . Sheets . SheetJS . C3 . w true > XLSX . utils . format_cell ( wb . Sheets . SheetJS . C3 , null , {dateNF : " YYYY-MM-DD " }); ' 2014-02-19 ' < -- uses the override ref:  https://github.com/Sheet...