ROOM64 / KNOWLEDGE / NOCODB

External Packages

Documentation for the external packages in NocoDB Scripts

อ่านต้นฉบับที่ NocoDB Official Docs ↗
เอกสารอ้างอิงภาษาอังกฤษเนื้อหาจากเอกสาร NocoDB คงรายละเอียดและโค้ดตามต้นฉบับ · ต้นฉบับอัปเดต 2026-09-25 ชื่อเมนูและฟีเจอร์ที่ใช้ได้ขึ้นอยู่กับเวอร์ชันและรุ่นที่ทีมใช้งาน

Workflows · ระบบอัตโนมัติและ Scripts · External Packages

← API Reference

สารบัญในหน้านี้

Documentation for the external packages in NocoDB Scripts

NocoDB Scripts supports importing external JavaScript packages using dynamic imports , allowing you to leverage NPM libraries in your scripts.

Which type of imports are supported?

Only dynamic imports using import() are supported. Static imports ( import ... from '...' ) will not work.

Can I import any NPM package?

Not all packages will work.

✅ Works: Pure JavaScript/ESM libraries (e.g., lodash, dayjs, uuid, zod, axios).

❌ Doesn't work: Packages that require DOM (react-dom, jquery, chart.js) or Node.js APIs (fs, net, crypto Node module, express, sharp).

Tip: If it runs inside a Web Worker, it will usually work in NocoDB Scripts.

Why do some packages fail in NocoDB Scripts?

Scripts run in a Web Worker sandbox. This environment:

  • Has no DOM ( document, window, HTMLElement).
  • Has no Node APIs ( fs, process, child_process , native addons).
  • Disallows synchronous browser storage ( localStorage, document.cookie).

How do I import multiple packages?

Use separate dynamic imports:

const _ = (await import('lodash')).default;
const dayjs = (await import('dayjs')).default;

Do I need .default after import?

Many CDN-transpiled packages expose the default export at .default . If you see undefined , try:

const dayjs = (await import('dayjs')).default;

How do I pin a specific package version?

Include a version or semver tag in the CDN URL to avoid breaking changes.

const _ = (await import('https://esm.sh/lodash@4.17.21')).default;

Common gotchas & troubleshooting

  • Named vs default exports: Check the package's docs; you might need named imports:

    const { nanoid } = await import('nanoid');
    const { z } = await import('zod');
    
  • Tree-shaking: Import subpaths when available for smaller bundles (e.g., lodash-es functions).

Examples that work well

  • lodash / lodash-es
  • dayjs
  • zod
  • uuid
  • axios (uses fetch in browsers)

Examples that won't work

  • react-dom, jquery, chart.js, leaflet (DOM-bound)
  • express, fs-extra, sharp, sqlite3 (Node-only)
  • js-cookie (needs document.cookie)

Security considerations

  • Prefer pinned versions.
  • Review package reputation; avoid importing untrusted code at runtime.
  • Validate and sanitize any data flowing into third‑party libs.

Example: Full flow

// Load external libs
const _ = (await import('https://esm.sh/lodash@4.17.21')).default;
const dayjs = (await import('https://esm.sh/dayjs@1')).default;

// Query data
const customers = base.getTable('Customers');
const recordQueryResult = await customers.selectRecordsAsync();

// Group and format
const groupedByStatus = _.groupBy(recordQueryResult.records, r => r.getCellValue('Status'));
for (const [status, customers] of Object.entries(groupedByStatus)) {
  output.text(`${status}: ${recordQueryResult.records.length} customers`);
}
output.text(`Report generated on: ${dayjs().format('MMMM D, YYYY')}`);

Good to know

  • External packages are only available in browser environment and does not work in Webhook Scripts.
  • Important: Only dynamic imports using import() are supported. Static imports (e.g., import _ from 'lodash' ) are not supported.

  • Base : Documentation for the base object in NocoDB Scripts
  • Cursor : Documentation for the Cursor object in NocoDB Scripts
  • Table : Documentation for the Table object in NocoDB Scripts
  • View : Documentation for the View object in NocoDB Scripts
  • Field : Documentation for the Field object and Field Types in NocoDB Scripts
  • RecordQueryResult : Documentation for the RecordQueryResult object in NocoDB Scripts
  • Record : Documentation for the NocoDBRecord object in NocoDB Scripts
  • Session : Documentation for the Session object in NocoDB Scripts
เนื้อหาเอกสารอ้างอิงและภาพประกอบมาจาก NocoDB Official Docs · บทความแนะนำภาษาไทยเรียบเรียงโดย Room64 · เว็บไซต์นี้เป็นคู่มือประกอบการใช้งานโดย Room64 · เอกสารทางการ ↗

มีงานที่อยากให้ Software, AI หรือ Automation ช่วยอยู่ไหม?

เล่า workflow หรือปัญหาที่ทีมกำลังเจอ เราช่วยดูได้ว่าควรใช้ระบบสำเร็จรูป เชื่อมเครื่องมือเดิม หรือพัฒนาเพิ่มเฉพาะส่วนไหน

คุยกับเราทาง LINEhello@room64.net