Step ดึง npm lib โดยใช้ curl/wget และ manual upload เข้า nexus กรณีที่ nexus proxy ใช้งานไม่ได้

สำหรับ Blog เขียนขึ้นมา เพราะว่าอยู่เจอปัญหาว่าตัว npm ตัว nexus proxy ไม่สามารถดึงมาให้ได้ พยายาม npm install หลายๆรอบ เพื่อให้ nexus ดึงมาให้ แต่ตบตีไปเกือบครึ่งวันแล้วยังไม่ได้ และเดี๋ยวต้องเอาไปส่ง UAT แล้ว เลยได้ท่านี้ขึ้นมาครับ

Download npm lib via curl/wget

ปกติสำหรับท่านี้มี 3 แบบที่ดึง package ลงมาแบบ Offline ตัว Lib ที่มีปัญหา electron-to-chromium@1.5.160

  • ใช้ npm pack มันจะได้ไฟล์ .tgz ให้เลยครับ โดยตัวอย่างประมาณนี้
npm pack <LIB_NAME>@<LIB_VERSION>
# Example
npm pack [email protected]

Note: สำหรับวิธีการนี้ผมไม่ได้ใช้ เนื่องจากเครื่อง dev ถูก Set ENV ไปที่ nexus local ทางเดียว ไม่ให้ต่อ https://registry.npmjs.org ตรงตัว config lock ไว้ เลยไป 2 ท่าที่เหลือแทน

  • curl
curl -O https://registry.npmjs.org/<LIB_NAME>/-/<LIB_NAME>-<LIB_VERSION>.tgz
# Example
curl -O https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.160.tgz
  • wget
wget https://registry.npmjs.org/<LIB_NAME>/-/<LIB_NAME>-<LIB_VERSION>.tgz
# Example
wget https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.160.tgz

Manual upload เข้า nexus

  • Login In เข้า Nexus
  • เข้าไปในส่วน upload เลือก npm แล้วเลือกไฟล์ tar
  • ตรวจสอบไฟล์ พบว่าไฟล์ที่เอาขึ้นมา มันจะมองว่าเป็น private แทน ไม่ใช่จาก proxy


Discover more from naiwaen@DebuggingSoft

Subscribe to get the latest posts sent to your email.