Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.
TypeScript apifyautomationcrawlercrawlingheadlessheadless-chromejavascriptnodejsnpmplaywrightpuppeteerscraperscrapingtypescriptweb-crawlerweb-crawlingweb-scraping
refactor: drop `fs-extra` dependency (#3969)
Jindřich Bär7373844c21f4
diff --git a/packages/basic-crawler/package.json b/packages/basic-crawler/package.jsonindex db7b16f84..7064b6ead 100644--- a/packages/basic-crawler/package.json+++ b/packages/basic-crawler/package.json@@ -47,7 +47,6 @@"@crawlee/types": "workspace:*","@crawlee/utils": "workspace:*","csv-stringify": "^6.5.2",- "fs-extra": "^11.3.0","ow": "^2.0.0","tldts": "^7.0.6","tslib": "^2.8.1",diff --git a/packages/basic-crawler/src/internals/basic-crawler.ts b/packages/basic-crawler/src/internals/basic-crawler.tsindex 799738d66..d1145ca75 100644--- a/packages/basic-crawler/src/internals/basic-crawler.ts+++ b/packages/basic-crawler/src/internals/basic-crawler.ts@@ -1,4 +1,4 @@-import { writeFile } from 'node:fs/promises';+import { mkdir, writeFile } from 'node:fs/promises';import { dirname } from 'node:path';import type {@@ -85,7 +85,6 @@ import type {} from '@crawlee/types';import { isAsyncIterable, isIterable, RobotsTxtFile, ROTATE_PROXY_ERRORS } from '@crawlee/utils';import { stringify } from 'csv-stringify/sync';-import { ensureDir, writeJSON } from 'fs-extra/esm';import ow, { ArgumentError } from 'ow';import { getDomain } from 'tldts';import type { ReadonlyDeep, SetRequired } from 'type-fest';@@ -1991,14 +1990,14 @@ export class BasicCrawler<]);}- await ensureDir(dirname(path));+ await mkdir(dirname(path), { recursive: true });await writeFile(path, value);this.log.info(`Export to ${path} finished!`);}if (format === 'json') {- await ensureDir(dirname(path));- await writeJSON(path, items, { spaces: 4 });+ await mkdir(dirname(path), { recursive: true });+ await writeFile(path, `${JSON.stringify(items, null, 4)}\n`);this.log.info(`Export to ${path} finished!`);}diff --git a/packages/cli/package.json b/packages/cli/package.jsonindex e458ed173..b02e158aa 100644--- a/packages/cli/package.json+++ b/packages/cli/package.json@@ -48,7 +48,6 @@"@crawlee/templates": "workspace:*","@inquirer/prompts": "^7.5.0","ansi-colors": "^4.1.3",- "fs-extra": "^11.3.0","tslib": "^2.8.1","yargs": "^18.0.0"}diff --git a/packages/cli/src/commands/CreateProjectCommand.ts b/packages/cli/src/commands/CreateProjectCommand.tsindex 8163b9879..4f46d763e 100644--- a/packages/cli/src/commands/CreateProjectCommand.ts+++ b/packages/cli/src/commands/CreateProjectCommand.ts@@ -1,6 +1,6 @@import { execSync } from 'node:child_process';import { mkdirSync } from 'node:fs';-import { readFile, writeFile } from 'node:fs/promises';+import { mkdir, readFile, writeFile } from 'node:fs/promises';import { get } from 'node:https';import { dirname, join, resolve } from 'node:path';import { setTimeout } from 'node:timers/promises';@@ -9,7 +9,6 @@ import type { Template } from '@crawlee/templates';import { fetchManifest } from '@crawlee/templates';import { input, select } from '@inquirer/prompts';import colors from 'ansi-colors';-import { ensureDir } from 'fs-extra/esm';import type { ArgumentsCamelCase, Argv, CommandModule } from 'yargs';interface CreateProjectArgs {@@ -76,7 +75,7 @@ async function downloadTemplateFilesToDisk(template: Template, destinationDirect// Make sure the folder for the file existsconst fileDirName = dirname(file.path);const fileFolder = resolve(destinationDirectory, fileDirName);- await ensureDir(fileFolder);+ await mkdir(fileFolder, { recursive: true });// Write the actual fileawait writeFile(resolve(destinationDirectory, file.path), buffer);diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 461a48f64..7d7fc46c9 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -320,9 +320,6 @@ importers:csv-stringify:specifier: ^6.5.2version: 6.7.0- fs-extra:- specifier: ^11.3.0- version: 11.3.4ow:specifier: ^2.0.0version: 2.0.0@@ -453,9 +450,6 @@ importers:ansi-colors:specifier: ^4.1.3version: 4.1.3- fs-extra:- specifier: ^11.3.0- version: 11.3.4tslib:specifier: ^2.8.1version: 2.8.1@@ -1313,9 +1307,6 @@ packages:engines: {node: '>= 0.10'}hasBin: true- '@apify/[email protected]':- resolution: {integrity: sha512-eNWHnP8CeMBgYBFko6/NJhHNKnxjy9HtbKQy0rq75LuKeibnAcT+7kkQrr6JDyDzrZL1O96yRWEy+G3lC2eIZA==}-'@apify/[email protected]':resolution: {integrity: sha512-lyvwMXee8SJNjNyxhr+nSTNyvjyoxbxol51xikq9VytFOPNSEMz8N02mUAuLVJNqrnqCBFRybjeqZdg4Y5AZlA==}@@ -12959,10 +12950,6 @@ snapshots:dependencies:event-stream: 3.3.4- '@apify/[email protected]':- dependencies:- '@apify/log': 2.5.35-'@apify/[email protected]': {}'@apify/[email protected]': {}